Nightwatch .waitForElementVisible('#primary-btn') warning : WaitForElement found 2 elements Nightwatch .waitForElementVisible('#primary-btn') warning : WaitForElement found 2 elements selenium selenium

Nightwatch .waitForElementVisible('#primary-btn') warning : WaitForElement found 2 elements


You should try this

document.querySelectorAll("div[id='primary-btn']:nth-child(1)") 

In nightwatch :

browser.waitForElementPresent("div[id='primary-btn']:nth-child(1)")


It means that you have 2 elements in you page with an identical id. While the standard impose a unique name, it is not enforced in the browser. You can verify it by executing this command in your browser:

document.querySelectorAll("[id='primary-btn']")

Or:

$x("//*[@id='primary-btn']")

So to get the expected element, you need to extend your selector with another condition. It could be for example:

'#container-id #primary-btn'