MrDysprosium
8 years agoContributor
How to pass a value back to a TestComplete script?
Imagine you are using TestComplete on a home made calculator, and you want to confirm it's computing 2+2 correctly (answer should be 4). You have a script, "Compare.py" that should looks somethi...
- 8 years ago
I'm no Python guy... but generally speaking, doesn't matter what language.
Let's say that there is a text field in your calculator application that contains that answer. Let's say, in NameMapping, it looks something like
Aliases.MyCalculator.resultText
Let's say that object is a pretty standard text object. That means that the value of the result would be found in the "wText" property of the object.
So, with all that, given the function you defined in Python, to check 2+2 = 4, you'd perform 2+2 on your calculator and then do
CompareAnswer(Aliases.MyCalculator.resultText.wText)
Within your function, I'd probably convert the "n" parameter to an integer using aqConvert.VarToInt since you're comparing the parameter to the integer 4... this ensures that you are comparing apples to apples.