CSS selectors: How can I get the last element?

625 views
Skip to first unread message

Alex Schenkman

unread,
Apr 30, 2015, 10:41:50 AM4/30/15
to nightw...@googlegroups.com
Hi Nightwatchers,

In jQuery I can do $("someCSSselector:last)
And mozill has :last-child.

None of these seem to work with Nightwatch and Selenium.
How can I achieve the same behaviour?

Thanks in advance!

Ellen Wong

unread,
Apr 30, 2015, 4:49:31 PM4/30/15
to nightw...@googlegroups.com
:last-child should work.

browser.click('ul.example li:last-child')

This should click the last <li> element in the <ul> with class 'example'. 

Alex Schenkman

unread,
May 4, 2015, 2:35:27 AM5/4/15
to nightw...@googlegroups.com
Thank you Ellen!
:last-child did indeed work.
I was using it wrong.
Reply all
Reply to author
Forward
0 new messages