Forum Discussion

VictorLai's avatar
VictorLai
New Contributor
8 years ago

How to make object paths variable dependent in Keyword testing?

Hi,

 

     I've attached a picture of a simple example of  a keywordtest where the same click action is repeated in two different instances of the same application. The only difference between the 2 actions is the process name Process("ABACUS", 1) and Process("ABACUS", 2). Is there a way to say to set a parameter to this keyword test and then pass in a value at run time to specify which instance of the application i want the action to be performed in? and in the keyword test itself have it look something like Process("ABACUS", index)  as the process name? I tried doing this by setting up a "index" parameter, but when i run the test it does not evaluate the index portion of the path. Any idea what would be the best of way tackling this?

 

Thanks.

5 Replies

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    I believe that this index is the instance number of the executable. You can't specify it, it's up to Windows to set it. it depends to the order you used when you launched the executables.

  • VictorLai's avatar
    VictorLai
    New Contributor

    Thanks everyone for their replies.

     

    After playing around with this I managed to find a reasonably elegant way of targeting the particular "ABAUS" process that I wanted when there are multiple instances of it. The trick is to set the search criteria for "ABACUS" in the NameMapping -> Mapped Objects section to contain the Index of the process and make that dependent on a project variable, say, AbacusIndex. 

     

    When it came to the actual testing I then could change the AbacusIndex value and then call RefreshMapping() function to update the search criteria for ABACUS at run time. This allowed me to direct  keywordtest actions, which were written for a single instance of "ABACUS", at different instances of "ABACUS very easily.

     

     

  • NisHera's avatar
    NisHera
    Valued Contributor

    Do you really need to do test both application at same time?

    then you need to have parallel testing set up as mention below

    https://support.smartbear.com/testcomplete/docs/testing-approaches/parallel-testing.html?q=parallel+testing#_ga=1.70588953.809719160.1405381514

     

    But need simply test Version1 and 2 both (one afte another)

    1) Keep same name for V1 and V2 of the application

    2) Keep two versions in different folders.

    3)  In your project tested app give 2 names for each application and map accordingly.

    4) Now you can open selected application using  TestedApps.Abacus1.run

    https://support.smartbear.com/testcomplete/docs/testing-with/tested-apps/adding.html

    • VictorLai's avatar
      VictorLai
      New Contributor

      Yes, would like to run 2 instances of the same application at the same time. The tested application in question allows for SVN uploads and downloads of projects. But I need to keep this to a single test machine.

       

      Using script coding can handle this by simply passing a variable as argument and use the variable in the process path. The variable will be evaluated at run time and that will change the process path at runtime to refer to the desired process. But seems like when it comes to keyword testing i can't seem to specify a variable into the object path for it to evaluate  at run time.

       

      Is there a better way of handling this for keyword testing?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        "Process" is a method on the Sys Object.  Two steps in your Keyword test

        1) Use Call Object Method to call the Process method on the Sys object.  You can then pass variables into the parameters of that method for the process name and/or the process index

        2) Set Variable Value to Last Operation Result to take the result of the Process method and assign it to a variable you can use for other things.

         

        See screenshot: