Nightwatch click fails to click the element when the browser running the test does not have focus

2,336 views
Skip to first unread message

Rachna

unread,
Jul 17, 2015, 2:49:24 PM7/17/15
to nightw...@googlegroups.com
Hi,
  I have the following lines of code for my test:

   client.waitForElementVisible('@myelement', waitTimeOut, 'After the timeline is loaded, wait for the the field to be visible');
     .click('@myelement')
     .setValue('@myelement', status)
     .waitForElementVisible('@myButton', waitTimeOut, 'After entering the text, wait for the button to be visible')


Both the selectors used here are using id. The test fails with the following msg:

✖ After entering the text, wait for the button to be visible  - expected "visible" but got: not found


When I look at the running test I noticed that the  .click('@myelement') does not get executed even thought the element is visible, since the waitForelementVisible('@myelement') passes. As a result it fails to find @mybutton because this button only gets enabled when some text is entered in the text field @myelement.

Also a weird thing that I noticed was if I change the focus to the browser that is running the test, the element gets clicked and the tests pass, but if I remove the focus from the browser that's running the test the click fails. As weird as it might sound this happens every time.

The version of nightwatch that I'm using is 0.7.8

Has anyone encountered this issue or a similar issue? Any help/suggestions would be appreciated.

Thanks.
Rachna
Message has been deleted
Message has been deleted

Stephanie Madison

unread,
Jul 20, 2015, 9:13:53 AM7/20/15
to nightw...@googlegroups.com
Can you try running with --verbose and check for the `/click` post request?

Rachna

unread,
Jul 27, 2015, 11:14:39 AM7/27/15
to NightwatchJs, smad...@twitter.com
Hi Stephanie,
  With the verbose option I get the following log:

INFO Response 200 POST /wd/hub/session/f56006f4-c265-4985-a464-7a991e3567bb/element{ sessionId: 'f56006f4-c265-4985-a464-7a991e3567bb',
  status: 0,
  state: 'success',
  value: { ELEMENT: '1' },
  class: 'org.openqa.selenium.remote.Response',
  hCode: 1664054172 }
INFO Request: POST /wd/hub/session/f56006f4-c265-4985-a464-7a991e3567bb/element/1/click
 - data:  
 - headers:  {"Content-Length":0}
INFO Response 200 POST /wd/hub/session/f56006f4-c265-4985-a464-7a991e3567bb/element/1/click{ sessionId: 'f56006f4-c265-4985-a464-7a991e3567bb',
  status: 0,
  state: 'success',
  value: null,
  class: 'org.openqa.selenium.remote.Response',
  hCode: 705072408 }
LOG     → Completed command click (303 ms)
LOG     → Completed command useCss (0 ms)
LOG     → Completed command useCss (0 ms)

Also this issue only seems to be there for Firefox, for Chrome it works fine. The log output for click requests for the failing and non-failing tests seem to be the same.

Thanks,
Rachna
Reply all
Reply to author
Forward
0 new messages