Forum Discussion

cameron_shiell's avatar
cameron_shiell
Occasional Contributor
4 years ago
Solved

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

  • cameron_shiell's avatar
    cameron_shiell
    4 years ago

    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()

     

     

5 Replies

      • cameron_shiell's avatar
        cameron_shiell
        Occasional Contributor

        Unfortunately not.  I've tried both

        if aqString.Trim(Aliases.LandmarkTarget.Display_is_2.TextContainer.NormalOutput.Text) != 2:

        and

        if aqString.Trim(Aliases.LandmarkTarget.Display_is_2.TextContainer.NormalOutput.Text) != "2":

        and they're both returning the same error.

         

        By adding a function to convert the output to ascii, I can see that the return from the calculator is '8237508236' which translates an 'R%2R$', which is weird, but attempting to match that string also fails.