maxgalbu/nightwatch-custom-commands-assertions

problems with jqueryclick using headless (Jenkins)

achampton opened this issue · 4 comments

hi,
I have installed your custom commands, so that we could run our tests in Jenkins
https://github.com/maxgalbu/nightwatch-custom-commands-assertions

I am having some issues when running via headless or non-headless (i.e. browser=chrome)

"Send a Private message":function (browser) {
browser
.assert.jqueryElementPresent("h3('Private messages')")
.pause(4000)
.waitForJqueryElement("xxxx > li:last-child:visibile", 10000)
.jqueryClick("xxxxt > li:first-child")
.pause(4000)
.assert.jqueryElementPresent("h3('Conversation')")
.jqueryElement("xxxx123") //same element
.jqueryClick("xxxx123") //same element
.pause(6000)
.setValueAndTrigger("xxxx123", "Automation Rules 123$%^&* ;-)")
.keys(['\uE006'])
.jqueryElement("xxx1234")
.jqueryClick("xxx1234")

when i run NOT headless (browser=chrome), it works perfectly
but in HEADLESS via Jenkins, it is always failing

without headless OK
✔ Testing if element <h3('Private messages')> is present.
✔ Testing if element <h3('Conversation')> is present.
✔ Testing if element div:xxx123 is present.
✔ Testing if element <xxx1234('Send')> is present.
✔ Testing if element is present.

Headless NOK
✔ Testing if element <h3('Private messages')> is present.
✔ Testing if element <h3('Conversation')> is present.
✖ Testing if element div:xxx123 is present. - expected "present" but got: null

FAILED: 1 assertions failed, 2 passed and 10 skipped (9.598s)

what am i doing wrong?

what if you use .click() or getElement() instead of jqueryClick()? does it work?

if i use a .click

✔ Element <a.logout> was visible after 39 milliseconds.

ERROR: Unable to locate element: "ul.conversations-list > li:last-child"
using: css selector

ERROR: Unable to locate element:
"button.btn.btn-primary.pull-right.js-send-message" using: css selector

Unable to locate element: "ul.conversations-list > li:last-child" using:
css selector

Unable to locate element:
"button.btn.btn-primary.pull-right.js-send-message" using: css selector

FAILED: 2 errors and 1 passed (21.663s)

i think the problem is i am waiting for ajax to be completed, that is why i
was using jqueryclick, this is my HTML

[image: Inline images 1]

On 22 December 2015 at 12:07, Massimo Galbusera notifications@github.com
wrote:

what if you use .click() or getElement() instead of jqueryClick()? does it
work?


Reply to this email directly or view it on GitHub
#14 (comment)
.

So those .pause(4000) is you waiting for an ajax request to complete? If you're using jquery to do ajax request, you could check for $.active to see if there's a request running, then do something after

I've added a waitForJqueryAjaxRequest() that wait for all jquery ajax request before continuing, maybe it is of some help