Ask a Question

Using Set Variable in a Keyword testcase


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




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.


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?

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Community Hero

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.

[Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.

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.

Showing results for 
Search instead for 
Did you mean: