Open matisnape opened 8 years ago
You could try my test recorder which will generate the paths.
@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 :)
Whats the attraction with XPath, first time I've heard that css selectors weren't up to the task.)
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 :)
I think this can help https://github.com/san650/ember-cli-page-object/issues/567
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 likecontains
,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!