cameron_shiell
5 years agoOccasional Contributor
Basic CheckProperty issue
I'm just getting started with TestComplete so I was playing around with it and the Windows Calculator. I've created a basic python script to confirm that 1+1=2.
def basic_test():
Calculator = Sys.Process("Microsoft.WindowsCalculator")
LandmarkTarget = Calculator.UIAObject("Calculator").UIAObject("LandmarkTarget")
if not Calculator.Exists:
TestedApps.calc.Run(1, True)
# Confirm one plus one equals two
LandmarkTarget.Number_pad.One.Click()
LandmarkTarget.Standard_operators.Plus.Click()
LandmarkTarget.Number_pad.One.Click()
LandmarkTarget.Standard_operators.Equals.Click()
aqObject.CheckProperty(
LandmarkTarget.Display_is_2.TextContainer.NormalOutput,
"Text", cmpEqual, "<u+202d>2", False
)
if Calculator.Exists:
Calculator.Close()
The only problem is the CheckProperty fails and when I check the details... apparently it's got "2", but was expecting "2".lculato
I assume I'm missing something obvious?ails an
Ah, it's got some deep unicode formatting characters on either side of it that need to be split off. It's not brilliant, but I've added a function to do it:
def strip_unprintable_characters(input_string) return "".join([i if ord(i) < 128 else '' for i in input_string]).strip()