cancel
Showing results for 
Search instead for 
Did you mean: 

Basic CheckProperty issue

SOLVED
Highlighted
Occasional 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, "‭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".

Calculator_Details.png

I assume I'm missing something obvious?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Occasional Contributor

Re: Basic CheckProperty issue

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

 

 

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

Re: Basic CheckProperty issue

I would use the Trim function from aqString on the text from the calculator just to make sure there's nothing hidden.  

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/methods.html

 

 

Highlighted
Community Manager

Re: Basic CheckProperty issue

Thank you Marsha!

 

@cameron_shiell did the advice help you figure this out?🙂


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
Occasional Contributor

Re: Basic CheckProperty issue

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.

Highlighted
Occasional Contributor

Re: Basic CheckProperty issue

Ah, it appears 8237 is ascii for the right-to-left override, and 8236 is ascii for pop directional formatting, so it's a problem of string formatting.  What fun.

Highlighted
Occasional Contributor

Re: Basic CheckProperty issue

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

 

 

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors