Results 1 to 2 of 2
  1. #1

    Calling Java Method in QTP Script


    I need to add verifications in to my script to test that the display text for TimeZone and Locale are correct based upon language presentation. My developers told me that to get the display text they are using SUN java object's getDisplayText(curentLocale).

    I've been looking at this for long enough that it's time to just ask for advice. And I did look through the forum for an answer but couldn't find one. I can find information about calling Javascript. And the Java Add in allows you to use object methods for specific objects on the screen, but how would I call just this function in a qtp script? Is there a way to do it?

    Thanks for any assistance.

  2. #2

    Re: Calling Java Method in QTP Script

    I can think of two ways, both of which are quite an overkill compared with finding a VBScript way of doing things:

    1. Write your Javascript command in a JS file, and now you can run it via QTP by : SystemUtil.Run "wscript.exe", "c:\yourfile.js"

    The only problem is, how can you report the Javascript result back to QTP. I can think of 2 ways :
    A. Have your Javascript report its results to a text file (via fso, or whatever method you use to write text files). QTP can read the file's content and get the result.
    B. Have your Javascript pop a message-box with the result as the text (e.g. by using wscript.shell object with pop-up method).
    Now you can access the message-box from QTP (just like you access any object of the AUT), rip out the text, and get the results.

    2. Use J#, not Javascript. once you write a J# dll, you can call it from QTP by the DotNetFactory auxiliary object. Now you don't need to mess with writing to files, since you can have your method return the result right back to QTP.
    'coz we're programmers - not users



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 04:06 PM.

Copyright BetaSoft Inc.