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

Feature request: XPath support #250

Open
matisnape opened this issue Sep 5, 2016 · 5 comments
Open

Feature request: XPath support #250

matisnape opened this issue Sep 5, 2016 · 5 comments
Labels

Comments

@matisnape
Copy link

I'm currently looking for a framework for ember e2e tests that handles promises without waits and sleeps, but I need XPath support to be able to define more complicated page elements in page objects.
For the tests not to be flaky, I can't use selectors like nth child - I rely very much on extracting the text from elements by using helpers like contains, following, logic operators and node functions - I use a lot of items from this cheatsheet http://ricostacruz.com/cheatsheets/xpath.html.

Examples of my elements:
//td//*[contains (text(), '" + field_name + "')]/../.. (field_name is passed as a param in function)
//td//*[contains (text(), 'name')]/../../following::td//option[@value='response." + el_name + "'] (el_name passed as a param in function)
//div[contains(@class, 'wysiwyg-creator-column') and not(contains(@class, 'ng-hide'))]//button[@ng-click='createNewElement()']/..

Overall, XPath is more versatile than CSS. It would be awesome if it could be supported. Thanks!

@matisnape matisnape changed the title XPath support Feature request: XPath support Sep 5, 2016
@san650 san650 added the feature label Sep 8, 2016
@quantuminformation
Copy link

quantuminformation commented Aug 29, 2017

You could try my test recorder which will generate the paths.

@matisnape
Copy link
Author

@quantuminformation thanks, but I know how to find paths, I'd just like to make them less brittle and no recorder will help me with this if xPath is not supported :)

@quantuminformation
Copy link

Whats the attraction with XPath, first time I've heard that css selectors weren't up to the task.)

@emattias
Copy link

emattias commented Nov 30, 2021

Finding elements by the visible text allows us to write tests that find the elements in the same way that the user does. This is one of the guiding principles of testing library. It would be nice to be able to do this with ember-cli-page-objects. XPath is a way to do this.

This way the test depends less on the implementation of the component/thing/whatever and more on what the user sees/uses.

One way to solve this could be to allow us to send in an element rather than a selector so we can use whichever selecting method we want :)

@ro0gr
Copy link
Collaborator

ro0gr commented Jan 30, 2022

I think this can help #567

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

No branches or pull requests

5 participants