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

Find by xpath #1511

Closed
rulrok opened this issue Apr 22, 2020 · 1 comment
Closed

Find by xpath #1511

rulrok opened this issue Apr 22, 2020 · 1 comment

Comments

@rulrok
Copy link

rulrok commented Apr 22, 2020

What problem does this feature solve?

Create a xfind method which allows for xpath selectors as an alternative to css selectors of find method.

What does the proposed API look like?

Currently: wrapper.find('a#abc[for="xyz"]')
Proposed: wrapper.xfind('//a[@id="abc"][@for="xyz"]')

Currently: wrapper.find('ul > li')
Proposed: wrapper.xfind('//ul/li')

Currently: wrapper.find('h1:not([id])')
Proposed: wrapper.xfind('//h1[not(@id)]')

Other examples:

Arithmetic
xfind('//product[@price > 2.50]')

Or logic
xfind('//a[@name or @href]')

XPath examples taken from here

@lmiller1990
Copy link
Member

Hi! We are looking to release v1 of this library in the near future and are not looking to add any additional features at this point.

I would recommend either using a unique test identifier (eg data-testid) if you need to find a component and a regular querySelector syntax is not specific enough.

v2 of this lib, which will target Vue 3, will have a kind of plug-in feature where you can add this feature yourself. See here for the current implementation (which is a WIP).

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