Skip to content

UI Recorder unnecessarily applies starts-with formatting to AutomationId attribute #1671

@hagi845

Description

@hagi845

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions