nightwatch: Clicking does not work
When I try using the click function in nightwatch.js, sometimes it does not work. For example,
.waitForElementVisible('.test')
.pause(500)
.click('.test')
When I run the command in verbose, it states that the click was a success, but nightwatch.js didn’t actually click on the element; it didn’t go to the next page. What should I do to fix this?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (1 by maintainers)
This dev is pretty oblivious of this click issue while there are about 20 tickets that addressed this. In Selenium Webdriver, all of my clicks are working fine. When using Nightwatch and building the same test I did in vanilla Selenium, the clicks do not work. That doesn’t look like a Selenium issue, it looks like a Nightwatch issue. We might abandon using Nightwatch, since there’s obviously no good support from the developer and our tests are working a lot better in vanilla Selenium. Some issues are yours dude, not another libraries’.
Yes, I need always add .pasue() after waitForElementVisible(), I do not how about others framework works, IMHO it doesn’t looks good.
If anyone is still having issues here, this worked for me:
.waitForElementVisible(‘button’, 1000) .pause(1000) .click(‘button’)
Just waiting and asserting that the element was there didn’t work, but adding in a pause made it work.
Hopefully this helps!
Looks like an issue with your test, not with nightwatch. Please note that the Mailing List is the appropriate tool to ask for assistance.
Quick question for those of you still seeing this issue. Does the button you’re trying to link have an onClick that calls preventDefault()?
I have exactly the same issue. Have to use hacky approach which works:
Any idea why such a simple function does not work?
In my case, no.
Same for me, nightwatch do not do the click on some elements (for me it’s a “a[id=LanguageButton]”). I’ve try in javascript and the click work : Ext.select(“a[id=LanguageButton]”).elements[0].click()
Dbaronov technic work, you save my day.