Click event is not triggered in Nightwatch.js on MacBook using Chrome

1,485 views
Skip to first unread message

Cp6uja

unread,
Jan 18, 2017, 9:04:55 AM1/18/17
to NightwatchJs

As a relatively new guy in nightwatch.js and in test automation using javascript i am facing many problems which i solved somehow, but now i am faced with one problem that i am not yet able to fix it.

The thing is next, nightwatch is able to locate the element as visible but it's not able to click on it. And this is only happening on MacBook, also i have to mention that on windows environment everything is working as expected.

The things i have tried so far are:

The first solution:

//expand hover menu

 .waitForElementVisible('@hoverMenu', 1000)

.click('@hoverMenu')

//wait one second and click on logout button

.api.pause(1000)

.assert.visible('@logoutBtn')

.click('@logoutBtn')


The second solution:

//expand hover menu

 .waitForElementVisible('@hoverMenu', 1000)

.click('@hoverMenu')

//wait one second and click on logout button

.click('@logoutBtn',function(){

this.waitForElementVisible('@logoutBtn',10000);

this.click('@logoutBtn');

})

And here is the error code i am getting

✔ Element <#app > div > div > aside > div.header__rightbarHeader___nXVZ2 > div.radialMenu__radialMenu___2Xy3S.header__mediaMenu___3aHzZ > span> was visible after 45 milliseconds.

✖ Testing if element <@logoutBtn> is visible. Element could not be located. - expected "true" but got: "null"

The problem is that assert is always passing and when it has to trigger the click event it will always fail. Also strange thing is that in error message in passed test i am getting full path reported and on the failed one only '@logoutBtn' which is part of page object abstraction.

I am using selenium-server-standalone-3.0.1.jar and the latest version of chromedriveravailable. And the site i am working on is made in ReactJS.

Thanks in advance guys ;)

Eric Mumford

unread,
Jan 31, 2017, 10:16:05 AM1/31/17
to NightwatchJs
I faced this problem with a link that was visible in the DOM, but had not yet rendered in the browser view window.

I solved this by executing JS in the browser object that scrolled the element into view. That made it clickable.

.waitForElementVisible('@element',w10)
.api.execute(function() {
document.getElementById("element.css").scrollIntoView();
});
Reply all
Reply to author
Forward
0 new messages