Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way we can use starts-with or contains in Xpath for @AutomationId #82

Open
Muthuvenaktesh opened this issue Feb 20, 2023 · 3 comments

Comments

@Muthuvenaktesh
Copy link

can we use starts-with or contains in Xpath for @AutomationId, currently it works with @name

@noubar
Copy link
Contributor

noubar commented Feb 21, 2023

valid example
//Button[@AutomationId='this is the id' and contains(@name, 'this the name')]
//Button[contains(., 'this the name or the id')]

Invalid unless the robot has admin privilages for some apps (maybe). Otherwise it should also work fine
//Button[contains(@AutomationId, 'thisistheid' )]

@Muthuvenaktesh
Copy link
Author

Muthuvenaktesh commented Mar 16, 2023

@noubar @Nepitwin

Thanks I am able to find the xpath with //Button[contains(., 'this the name or the id')].

Is there any we can loop through the elements, If more elements are found for the above condition.

I want to validate whether the first occurrence of the Id has specific parameters and second has different parameters.

Tried using //Button[contains(., 'this the name or the id')][2 or 3] it didn't work, it was able to find the first occurrence only.

@noubar
Copy link
Contributor

noubar commented Mar 25, 2023

Currently we support only first occurence. Which should be enough because usually in app (gui under test) side, if it is ui automation friendly. It should always support unique automationid or name for specific element. Thus the element will have an unique xpath which can not occure more than once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants