SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4

Thread: JS Newbie

  1. #1
    Senior Member
    Join Date
    Apr 2008
    Posts
    187
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    JS Newbie

    We've been using QTP for several years. Too expensive, evaluating the change to TC. So far, some of the test architecture is going well, others not so much. Anyway, decided to use JS instead of VB because of the try/catch. That's not my question. I want to see if an application (Java) has launched. So I have something like this:

    var appLaunched= Sys.Process("javaw").SwingObject("ClinicGUI", "Client Health Clinic", 0).Exists;
    Log.Message(appLaunched);

    No worries, this workd fine. However, I want to capture that object in a vairable, so I can use it all over the place and I haven't figured out just how to do that. I've searched, but I can't find the answer.

    For example, in VB script, I could do something like this:

    Set myApp = Sys.Process("javaw").SwingObject("ClinicGUI", "Client Health Clinic", 0)

    Then I can use myApp.Exist, myApp.Displayed, etc. In JS, this does NOT work:

    var myApp = Sys.Process("javaw").SwingObject("ClinicGUI", "Client Health Clinic", 0);
    var appLaunched = myApp.Exists;
    Log.Message(appLaunched);

    I can't figure out the syntax to make it an object instead of a string. Probably something novice......

  2. #2
    Senior Member
    Join Date
    Apr 2008
    Posts
    187
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: JS Newbie

    Never mind, I'm an idiot. I got it.

  3. #3
    Moderator tristaanogre's Avatar
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA
    Posts
    1,792
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: JS Newbie

    I'm not sure what your problem is. Are you getting an error message? If so, which line is the error occurring on? What is the text of the error?

    A couple of notes, though. If you're code is to check to see if an object exists, your best bet is not to use SwingObject but WaitSwingObject. The reason being is that if you use the code you suggested and the object does not exist, you will get an error indicating that "Exists is not a valid property or method" or some such thing, most likely an error, even in the assign statement to try and assign the object to myApp. I'd suggest the following minor code change.

    <font class="small">Code:</font><hr /><pre>var myApp = Sys.Process("javaw").WaitSwingObject("ClinicGUI", "Client Health Clinic", 10000);
    var appLaunched = myApp.Exists;
    Log.Message(aqConvert.VarToStr(appLaunched));</pre><hr />

    Let me know if this works and, if not, what errors you get in the process.
    -Robert Martin
    Automated Testing Evangelists
    TestComplete "expert"
    Definition expert - noun - Unknown drip under pressure

  4. #4
    Senior Member
    Join Date
    Apr 2008
    Posts
    187
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: JS Newbie

    Thanks Robert, I figured it out, but your code is far more elegant. Works great. This transition from QTP to TC is going to be a bear. No pun intended.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:49 AM.

Copyright BetaSoft Inc.