0

What I have is:

 <a href="/test-guinea-pig2.html" id="i am a link">i am a link</a>

How would I go about clicking that using nightwatch.js? click() isn't working out.

Shayd3
  • 131
  • 1
  • 2
  • 12

2 Answers2

0

You click the same way you would do with a CSS selector:

browser.click('#my-id'). That said the id in your example is invalid (link to what is a valid id) so you better rewrite it like i-am-a-link or something better.

Community
  • 1
  • 1
Kev
  • 5,049
  • 5
  • 32
  • 53
0

if we use browser.click('#my-id') it will look in the entire dom to identify the element.

The better and faster way to do will be

.click('a[id="i-am-a-link"]')

by filtering using 'a' only the anchor tags in the dom will be searched for .

Ananda
  • 888
  • 9
  • 19