Nightwatch: CSS3 selectors

Created on 4 Sep 2014  Â·  8Comments  Â·  Source: nightwatchjs/nightwatch

Is there a way to select nth child of an element ? Or simply the first or the last ?
I've tried .click('#points td:first'), but Nightwatch returns me an error.

Thanks

All 8 comments

try #points td:first-child.

On Thu, Sep 4, 2014 at 3:38 PM, Guillaume Canu [email protected]
wrote:

Is there a way to select nth child of an element ? Or simply the first or
the last ?
I've tried .click('#points td:first'), but Nightwatch returns me an error.

Thanks

—
Reply to this email directly or view it on GitHub
https://github.com/beatfactor/nightwatch/issues/253.

don't work !

The selector is valid. Please provide more information on the mailing list
if you need help with anything.

On Thursday, September 4, 2014, Guillaume Canu [email protected]
wrote:

don't work !

—
Reply to this email directly or view it on GitHub
https://github.com/beatfactor/nightwatch/issues/253#issuecomment-54490023
.

Is there a doc or reference on what types of CSS selectors are supported? It doesn't look like all jquery or CSS3 selectors are supported.

It should support all the selectors that are working in the browser using document.querySelectorAll("selector"), just test the selector using document.querySelectorAll in your javascript console before putting it in the test.

Ok knowing it should support what document.querySelectorAll supports helps. Thanks!

Selectors like :first or :last are not really defined in W3C
recommendations to use with any HTML tag. Nightwatch rightly implements the
pseudo-selectors as defined in these recommandations
http://www.w3.org/TR/css3-selectors/

2014-12-01 14:57 GMT+01:00 Charles Himmer [email protected]:

Ok knowing it should support what document.querySelectorAll supports
helps. Thanks!

—
Reply to this email directly or view it on GitHub
https://github.com/beatfactor/nightwatch/issues/253#issuecomment-65067434
.

Guillaume CANU

Just tested that theory @gcanu and, while it may have been true at some point in the past, it is no longer true.

Using this syntax is correct, whereas using the one defined in the link you provided does not work for me, using latest Chrome on Ubuntu 16.04 LTS.

Works:

audiences-list > div > div > div:last-child .gap-audiences-list__item-title

Doesn't work:

audiences-list > div > div > div:nth-last-child .gap-audiences-list__item-title
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dakebl picture dakebl  Â·  4Comments

antogyn picture antogyn  Â·  4Comments

bushev picture bushev  Â·  4Comments

gary5 picture gary5  Â·  4Comments

aking1012 picture aking1012  Â·  4Comments