UIAutomation Name vs. UIAutomation Value

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
geoffwoz
Newbie
Posts: 8
Joined: Tue Jan 13, 2015 11:59 am

UIAutomation Name vs. UIAutomation Value

Post by geoffwoz » Wed Jun 15, 2016 2:15 am

Hi,

I know this is a simple case, but does raise a few questions that I'm not sure have already been answered...

If I utilise the UI functions such as UIClick it appears that the mach criteria for the object name applies some internal logic that appears to cause some problems. It appears that the match can be made on UI Automation Name or UI Automation Value (as indicated in the wizard).

In the case of automating good old calculator.exe, if I have a script as follows:

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
UIClick>{"Calculator"},{"8"}
UIClick>{"Calculator"},{"8"}

What happens is the first line will click on the button 8, the second line will click on the Result portion of the calculator window (this is because the result object in the UI now has a UI Automation Value of "8").

Is there any way that we can change the behaviour of this search to only search based on "UI Automation Name" rather than UI Automation Value ?

Looking at what I can see in the return from the UIAccessibleList I can see there does appear to be an object with name and value 8 here as well as the button and also as well as the Result object, so I'm guessing that is a part of the problem here... any ideas of ways that we could handle this ?

If we had a way to add an additional requirement to the action which allowed for you to also specify an object size that would allow the search to be more precise. I'm not sure if there is anything else that you could use ? anything that differentiates a button from a text field ??

Output of the UI AccessibleList below:


Code: Select all

System= [417,70,22x22]
 System= [417,70,22x22]
 Minimise= [530,63,28x21]
 Maximise= [558,63,26x21]
 Close= [584,63,47x21]
Application= [417,93,212x19]
 View= [417,93,39x19]
 Edit= [456,93,34x19]
 Help= [490,93,39x19]
Calculator= [417,113,212x264]
     Running History= [432,126,182x13]
      Running History= [432,126,182x13]
     Memory= [428,148,14x18]
      Memory= [428,148,14x18]
     Result= [446,138,167x28]
      Result=8  [446,138,167x28]
     8= [446,141,167x30]
      8= [446,141,167x30]
     Memory clear= [428,178,34x27]
      Memory clear= [428,178,34x27]
     Backspace= [428,210,34x27]
      Backspace= [428,210,34x27]
     7= [428,242,34x27]
      7= [428,242,34x27]
     4= [428,274,34x27]
      4= [428,274,34x27]
     1= [428,306,34x27]
      1= [428,306,34x27]
     0= [428,338,73x27]
      0= [428,338,73x27]
     Memory recall= [467,178,34x27]
      Memory recall= [467,178,34x27]
     Clear entry= [467,210,34x27]
      Clear entry= [467,210,34x27]
     8= [467,242,34x27]
      8= [467,242,34x27]
     5= [467,274,34x27]
      5= [467,274,34x27]
     2= [467,306,34x27]
      2= [467,306,34x27]

hagchr
Automation Wizard
Posts: 327
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: UIAutomation Name vs. UIAutomation Value

Post by hagchr » Wed Jun 15, 2016 7:49 am

Hi, I not very familiar with the technical aspects so hopefully someone else can reply. With MS14.2.9 and Win10 it seems to work just fine, one just have to change to UIClick>{"Calculator"},{"Eight"}. Are you using older versions?

The UIAccessibleList> would result in the following, where everything seems to be well structured:
System= [128,104,22x22]
System= [128,104,22x22]
Calculator= [128,96,270x512]
Calculator= [128,96,270x512]
Calculator= [128,96,270x512]
Calculator= [140,104,54x16]
History= [350,128,48x48]
Display is 88 = [128,196,270x72]
Clear Memory= [128,268,45x32]
Memory Recall= [173,268,45x32]
Memory Add= [218,268,45x32]
Memory Subtract= [263,268,45x32]
Memory Store= [308,268,45x32]
Memory= [353,268,45x32]
Percent= [128,300,68x51]
Square root= [196,300,67x51]
Squared= [263,300,68x51]
Reciprocal= [331,300,67x51]
Clear entry= [128,351,68x51]
Clear= [196,351,67x51]
Backspace= [263,351,68x51]
Divide by= [331,351,67x51]
Multiply by= [331,402,67x52]
Minus= [331,454,67x51]
Plus= [331,505,67x52]
Equals= [331,557,67x51]
Positive, Negative= [128,557,68x51]
Seven= [128,402,68x52]
Eight= [196,402,68x52]
Nine= [264,402,67x52]
Four= [128,454,68x51]
Five= [196,454,68x51]
Six= [264,454,67x51]
One= [128,505,68x52]
Two= [196,505,68x52]
Three= [264,505,67x52]
Zero= [196,557,68x51]
Decimal Separator= [264,557,67x51]
STANDARD= [128,128,161x48]
STANDARD= [188,143,89x20]

geoffwoz
Newbie
Posts: 8
Joined: Tue Jan 13, 2015 11:59 am

Re: UIAutomation Name vs. UIAutomation Value

Post by geoffwoz » Wed Jun 15, 2016 11:04 am

Hi hagchr,

Thanks so much for replying so quickly.

Sorry I probably wasn't overly clear in my initial description. Really the case of calculator was an example of a potentially problematic situation (one that was raised to me by one of our devs as a problem scenario). It's interesting that the new Windows 10 calculator is so different, was one of the last apps that I thought they'd be rewriting, but seems like they have. In this case the it seems they've rewritten with the UI Automation element names different, maybe to avoid just this sort of occurrence for their own automated tests :-)

I suppose though my problem situation could reoccur for other applications that exhibit the same problem (in my case it was windows8 calculator), and was wondering if there might be a way to handle the problem.

Basically the UIxxxxx functions appear to do a linear search of the UIautomation tree structure to find the first matching UI Automation name. I'm wondering if perhaps there was an ability to do something similar, but expose some additional conditions on the selection (such as, object type, object geometry) etc.. My guess is it's not in there, but would seem like a nice feature to make the script a litle more robust for potentially poorly written apps.

In our case we use macro scheduler embedded within our product, so the above probably seems a bit picky, but it would make the task of generating these embedded scripts a bit easier.

Anyhow, just a thought, again thanks for replying so quickly.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts