Forum Discussion

gdave's avatar
gdave
Regular Contributor
7 years ago
Solved

Changing Data

Recently my organisation has decided that data in our test will not be static and will change every month. Which means that my automation test its going to fail because it is unable to find the data I had specified.

 

I want to know if there is any way TC can recognise and copy the data displayed on the screen into my keyword test script ?

 

Example:

I search for a client using a client id.

The search returns client details including name, address, dob.

This above client details will change every month and only the client id will remain static

I want to design my test in such a way that that client name displayed on the screen is copied automatically elsewhere into my test script

 

Looking forward to hear a possible solution to this. Thanks

 

Regards

G

 

  • You would essentially use the "Set Variable Value" operation and, when selecting the variable, select your project level variable.  And, in the value, you'd select an Object property (see below screenshots)

     

     

    Then, let's say you want to enter that variable value into something else, like via a Keys operation.  Then, you would do something like this:

     

7 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Basically, you want to grab the data from the AUT and use them for further scenarios.

     

    If my understand is correct,  you can do the following.

     

    TestComplete not provide option to enter or select the values in GUI, It also provide option get the values from UI.

     

    In you scenario,

     

    I assume you will have Client ID.

     

    1. Search your client id and display the results
    2. Use Set Variable Value option in keyword test to store the Client details in Project Variable.
    3. Use this link to get knowledge on how to use the variables in the keyword test operations. Based on this you can re-use the stored client details in further keyword steps.
    • Marsha_R's avatar
      Marsha_R
      Champion Level 3

      Our data changes every time we run the tests.  We use the solution that shankar_r suggested to pass values back and forth.

    • gdave's avatar
      gdave
      Regular Contributor

      Hi

       

      Sorry for the late reply.

       

      I think I didn't explain my scenario very well.

       

      So our organisation is in the process of masking client data which means that only the unique client id will be static and rest of the client data (first name, last name) will change every time there is data refresh. Now, what my test does is that it enters client id in the client id search field and then uses the displayed client name for rest of my keyword test. This is fine if the client name is same everytime, however, imagine a scenario where a different client name is displayed everytime you perform a search with client id....... This will cause my test to fail because the client name I had entered is now changed and TC is unable to recognise it.

      So I was thinking if there is any way that TC can capture the client name value automatically from the name field into a variable etc so that I can then use in it rest of my keyword test ?

      Hope this is clearer now. Thanks

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        The answer to your question is: Yes.

         

        I know, short answer.  But generally speaking, if you put the search in for the Client ID and the names and such are displayed on the screen, you can "scrape" what's there via properties of the objects containing that text and populate them into Project level variables (see https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-project-suite/about.html).  Storing the values in there will make those values available in all scripts and keyword tests throughout your test project without needing to pass in parameters or such.

         

        Now, it's not "automatic"... you'll have to write some sort of code routine, either script or keyword test that, when you do the Client ID search, assigns the values to the variables, but it is possible to do what you want.  Say that the Client's name is stored in some object referenced as

         

        Aliases.myApp.formClientInfo.textboxClientName

         

        and you have a Project variable call clientName.    Your code MAY look something like this

         

        function storeClientInfo(clientID){
            SearchForClient(clientID); //just a place holder, really, for whatever code is doing the search
            Project.Variables.clientName = Aliases.myApp.formClientInfo.textboxClientName.wText;
        // repeat similar code for all data you want to store
        }

        Then, any place throughout your test project you want to access that data, simply reference Project.Variables.clientName.