Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Calling methods that take arguments

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
I have a bunch of forms that not only change based on a users settings but also are being enhanced with new options every code cycle (little less than 6 weeks) I'm trying to get around webking updating the form itself since it sometimes fails and I have to manually go in and add a new form to replace the old. (I'm dealing with about 100+ different forms and my paths use the forms many times over so a couple not updating takes along time to fix)

What I want to do is have a library of methods or functions that I can call. For example I want to login so instead of using a form I just call "login(user, pw);" or something to that effect. So when another value is added to the form say secret, then I just go in and add a function inside of login that fills in the secret. Also I can start using that new function from now on when adding new login test cases.

I tried using pre(post)-traversal in the action tab but that won't let you pass values to method calls. I'd really like to just add a javascript test and call the function. Is that possible?

Thanks

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Answered my own question using a directory to host a bunch of js files.

    FYI for those ever having the same issue. Go under Customize Preferencs> Misc Tab> Scroll Down to External JavaScript Test Functions.

    May want to incorporate some java classes, anybody know how to create java objects in javascript. The manual has an example of calling the webking api but I can't seem to get the syntax right to use the java api.

    Thanks
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    edited September 2006
    Options
    In order to create Java objects in Javascript you need to specify the full class name of the type of object you'd like to create.

    For example:

    var hw = new java.lang.String("hello world");

    Though I haven't tried in WebKing, it is possible to load 3rd party Java classes into Javascript using a URLClassLoader. In order to access these classes once they have been loaded, you need to add the prefix "Packages"

    For example

    var hw = new Packages.com.test.example.HelloWorld();