If you are using Nightwatch JS to test a website and you need to test an anchor nested in an unsorted list, be sure to add the name attribute in the anchor, otherwise, the click command will fail. Let’s see a simple case with an HTML markup like this:

<ul>
 <li>
  <a id="page-link" href="/pages">
    Page
  </a>
 </li>
</ul>

The Nightwatch test below will fail the click.

module.exports = {
  'Test' : function( browser )
  {
    browser 
      .assert.elementPresent( "#page-link" )
      .click( "#page-link" )
      .end();
  }
};

You can fix it by using:

<ul>
 <li>
  <a name="page-link" href="/pages">
    Page
  </a>
 </li>
</ul>

and

module.exports = {
  'Test' : function( browser )
  {
    browser 
      .assert.elementPresent( 'a[name="page-link"]' )
      .click( 'a[name="page-link"]')
      .end();
  }
};