WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

UI Recorder unnecessarily applies `starts-with` formatting to AutomationId attribute

Open hagi845 opened this issue 4 years ago • 1 comments

We have confirmed the phenomenon that the AutomationId attribute is not generated correctly when generating xpath using UIRecorder.

After reading the source code, the possible causes are as follows.

In the AutomationId path generation process, there is a description that generates a path in starts-with format if the count that matches the regular expression (^([^¥d]*)[_¥.¥-¥d]+$) is equal to or greater than 2, there is a description that generates the path in starts-with format.

https://github.com/microsoft/WinAppDriver/blob/master/Tools/UIRecorder/UIRecorder/GenerateXPath.cs#L399

For example, a string ending with a number such as textBox1 falls under this category, so the path will be generated in the starts-with format as follows.

Edit[starts-with@AutomationId,\"textBox\")]

Why do an ambiguous search for starts-with when you can get a value that uniquely identifies the element textBox1?

In fact, when I created textBox1 and textBox2 and retrieved their xpaths, they generated exactly the same path, even though the elements were different.

image image Verified in Visual Studio 2022.

hagi845 avatar Jan 21 '22 08:01 hagi845

Hi, I'm facing the same problem with the recorder. Were you able to find any solution? @hagi845

Nistha-tech avatar Mar 14 '23 03:03 Nistha-tech