Forum Discussion

cmbdnne's avatar
cmbdnne
Occasional Contributor
6 years ago

Does anyone know how use a value from keyword test A and use it in test B, also when updated in A?

 

Hi TestCompleters!

 

I have recorded two separate keyword tests, let's call them test A and test B.

What I would like to do is to use a value created by an Object Checkpoint - generated in test A in test B and preferably in a way so that if the value changes in test A, then the new value is automatically transferred/updates in test B - is that possible?

 

I reckon the solution somehow involves the creation of variables (I do not use script) and have tried to apply the method here:

https://support.smartbear.com/screencasts/testcomplete/using-variables-in-keyword-tests/

But come up against a brick wall when trying to locate the Objects Property Viewer - the video uses TestComplete version 7.50 and I use version 12.50 so I reckon that a lot has changed since then:

 

- Does the "Objects Property Viewer" button still exist in TestComplete version 12.50? Or has it been renamed to "Object Spy"?

 

Any suggestions are enthusiastically acccepted!

Thank you in advance

7 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    In Test A, use the operation "Set Variable Value" to create a variable on the Project level that contains the desired value you want to pass over to test B.  

     

    Then, in Test B, whatever operation you are wanting to use the value in, there should be a parameter of some sort.  That parameter has a "mode".  Set that mode to "Variable" and then select the project variable.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I see you keep editing your post... but I'm not sure what the problem is.  Object Spy/Object Property Viewer are not directly related to being able to use data from one Keyword Test in another (it's been quite a number of years since I've played with TestComplete 7 but I'm sure Object Spy is what you're looking for with regards to investigating an object).   

     

    If the answer I gave was unhelpful, let me know what you still need and I'll try to help.

    • cmbdnne's avatar
      cmbdnne
      Occasional Contributor

       

      Thanks a lot for your input so far.

       

      I've edited my post several times as I'm trying to describe my issue as clearly as possible (hasn't been very successful so far ;)

       

      1. I start recording a test, Test A. During this test an asset value is created and I checkpoint this value and keep on recording.

       

      2. I keep recording Test A and at some point need to insert the the value above in a text box - and I would like my test to do this automatically when I re-run Test A.

      This is because the value of the asset created in test step 1 automatically goes from, e.g. 1 to 2 to 3 to 4 etc every time this test step is re-run

       

      3. Another issue is that during the creation of this asset, a description of the asset must be entered in another text box - this could e.g. be abc1000 or anything else.

      As this description DOES NOT automatically increases from abc1000 to abc1001 to abc1002 every time this test is re-run, I need a way to make this happen if possible?

      I've considered options such as a cleverly created variable, a test parameter or a data loop in which the description increments are loaded from an Excel sheet.

       

      As I admittedly am a TestComplete newbie, any test "recipes", as detailed as possible, are warmly welcomed.

      I can upload screen shots if my problem description still appears unclear.

       

      Have a nice weekend!

       

      Best regards,

      //Camilla

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        So, you're not passing values from one test to another, you're basically, within the same test, want to take a value that you "collect" at one point in the test and use it in another.  

         

        Again... Set Variable operation is how you're going to do this.

         

        So,  based upon your steps, you will need to do this stuff AFTER you complete the recording., or, when you get to these points in your recording, Pause your recording and add the necessary operations, edits.  

         

        1) When  the asset value is created as per your step one, use Set Variable Value operation to set a variable to the asset value as it is created.  In anticipation of item 3 below, you would also use Set Variable Value to set ANOTHER variable as the description of the asset.

         

        2) When you get to the point where you need to insert the value in a text box, whether you use the Keys methods or SetText method to enter the data in the text box, there is a parameter on the method which you can set to be of "Mode" variable at which point you select the variable indicating in item 1 above as the source of the data

         

        3) As with item 2, again, you would use the Variable mode of the Keys/SetText method parameter and select the second variable as your entry into the text box.

         

        There is no need for a test parameter, data driven loop, or anything particularly clever.  Think og it in the same way as you would if you were manually testing it.  You create the asset and, on a piece of paper, you jot down the asset value and the asset description.  Then, when you get to the relevant points of your test, you reference your piece of paper and use those values to enter the data into the application.  Variables are your "piece of paper" in this situation where you note your values and then use them later.