Forum Discussion

OlgaB's avatar
OlgaB
Occasional Contributor
12 years ago

TC problem when application’s window name is changing

When our application is opened the window name contains the names of the server and database. If we point it to another server all my tests stop working. I think this is because the object name contains the server name. Is there any solution for this problem?

5 Replies

  • Tom_E's avatar
    Tom_E
    Occasional Contributor
    Have you considered passing in the name of the server as a parameter?
  • OlgaB's avatar
    OlgaB
    Occasional Contributor

    Passing where? I don’t use all these names in my tests. What is happening, I think, my tests were recorded with some objects. TC mapped them and used them in my test. For example TC found and mapped the following object


    “Sys.Process("myappl").SWTObject("Shell", "Myapplication - user@server2008 - QA_SQL2008_65:1433").SWTObject("Composite", "", 5)”.


    Then I pointed my application to another server and the object became


    “Sys.Process("myappl").SWTObject("Shell", "Myapplication - user@AnotherServer2008 - QA_SQL2008_65:1433").SWTObject("Composite", "", 5)”


    TC find new object and mapped it differently. In first case it is Shell1, in second case it is Shell60.


     

  • witte's avatar
    witte
    Occasional Contributor
    You can use wildcards * in the name (Shell*).

    Or you don't define the object by his name. Use the Find or FindChild Method and search for Property/Value which is available of this object.



    Hope it helps.
  • witte's avatar
    witte
    Occasional Contributor
    In addition to my last post:

    =================

    Object should be found if you use the wildcards as in following example:

    => Sys.Process("myappl").SWTObject("Shell*",
    "Myapplication - *").SWTObject("Composite", "", 5)



    But I'd like to give you a notice for better scripting. It's not a patch on you!

    1) you shouldn't use capture and replay without changing some code. This is because names or indexes and so on may change during test and test script has to be changed evry time. This is not effective :-)



    2) Use variable and check if object exists, then further on with next steps. That makes more stable the testrun.

    => Example:

    var appName = "myappl";

    var application = Sys.Process(appName);



    //use any unique property or more if neccessary

    if(application["FindChild"]("ObjectIdentifier", "Myapplication - *", 10, true)["Exists"]){

       myApp = application["FindChild"]("ObjectIdentifier", "Myapplication - *", 10,false);   

       //if you need the index too, then define array with params and values

       myApp["FindChild"]("Name", "Composite", 5, true);

    }


  • OlgaB's avatar
    OlgaB
    Occasional Contributor

    Thanks SW. It works now :)
    . When I saw your suggestion to use wildcard I started to imagine how many
    objects I need to modify. But actually I had to change a couple.