Forum Discussion

rpd's avatar
rpd
Contributor
6 years ago
Solved

Using Set Variable in a Keyword testcase

What I was trying to do was to simply show the value of a variable in the test log associated with a KEYWORD testcase. For some reason the value of the Project variable named TotalTax is NULL.

 

I used the Set Variable wizard tool to define the TotalTax variable as the value of an object on the target web page

This worked fine.  When I used this wizard, the value of the TotalTax variable was set to "= 26,808.88".

 

The MODE setting for this parameter was set to OBJECT PROPERTY. The VALUE setting for this parameter was set to

 

Aliases.browser.pageAutawb21SalestaxwebGotosucce.table.cell5.contentText

 

Note that the project variable, TotalTax has a TYPE set to STRING. I tried a TYPE set to OBJECT, and then TestComplete complains of a TYPE MISMATCH error when the Set Variable Value statement is executed.

 

This TYPE MISMATCH error is shown under the Additional Details tab of the test log.

 

Any help with this question would be appreciated. Thanks.

 

  • Here's my thinking:

    I'm guessing that you're setting the variable value after some other process.  So, it's entirely possible that, at the time that "Set Variable Value" is called, that there is no contentText or object of the type you're looking for.  Essentially, a timing issue where the value is not getting set because the component isn't fully rendered yet.

    Could you post a screenshot of your keyword test including the steps leading up to the Set Variable Value call?

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Here's my thinking:

    I'm guessing that you're setting the variable value after some other process.  So, it's entirely possible that, at the time that "Set Variable Value" is called, that there is no contentText or object of the type you're looking for.  Essentially, a timing issue where the value is not getting set because the component isn't fully rendered yet.

    Could you post a screenshot of your keyword test including the steps leading up to the Set Variable Value call?

    • rpd's avatar
      rpd
      Contributor

      Thank you Robert for your reply. It reminded me that I had to WAIT an appropriate amount of time before using the SET VARIABLE command in my test case.

       

      Once I added a Find Object command for the contentText {GET] operation associated with the object I was looking for, the SET VARIABLE commnd did assign the value I expected to the TatalTax variable.

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Also, the type mismatch is because your Object Property is actually text (ContentText) and not an Object.  Leaving your variable as type String is fine.