Nightwatch: waitForElementVisible using xpath not working when parameters are not named

Created on 29 Aug 2019  Â·  4Comments  Â·  Source: nightwatchjs/nightwatch

With v1.2.1, the following will fail with the error message

//main//header[1]/form/input - expected "visible" but got: "not found"

browser.waitForElementVisible('xpath', '//main//header[1]/form/input');

However, the following code succeeds with

✔ Element was visible after 2039 milliseconds.

browser.waitForElementVisible({
  locateStrategy: 'xpath',
  selector: '//main//header[1]/form/input'
});

Your Environment:

Please include the following:

  • Nightwatch version: 1.2.1
  • Node.js version: 10.15.0
  • OS: OS X 10.13.6
  • Browser driver: chromedriver
  • Browser driver version: 2.38.552518
  • Selenium server version: 3.14.0

Verbose log of failing code

   → Running command: waitForElementVisible ('xpath', '//main//header[1]/form/input')
   Request POST  /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements  
   { using: 'css selector', value: 'xpath' }
   Response 200 POST /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements (1016ms)
   { sessionId: '0059af23f9df03127d897b001a311ffe',
     status: 0,
     value: [] }
   Request POST  /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements  
   { using: 'css selector', value: 'xpath' }
   Response 200 POST /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements (1012ms)
   { sessionId: '0059af23f9df03127d897b001a311ffe',
     status: 0,
     value: [] }
   Request POST  /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements  
   { using: 'css selector', value: 'xpath' }
   Response 200 POST /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements (1012ms)
   { sessionId: '0059af23f9df03127d897b001a311ffe',
     status: 0,
     value: [] }
   Request POST  /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements  
   { using: 'css selector', value: 'xpath' }
   Response 200 POST /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements (1014ms)
   { sessionId: '0059af23f9df03127d897b001a311ffe',
     status: 0,
     value: [] }
✖ //main//header[1]/form/input - expected "visible" but got: "not found"
    at process._tickCallback (internal/process/next_tick.js:68:7) 

 → Completed command waitForElementVisible ('xpath', '//main//header[1]/form/input') (5574ms)
 → Running [afterEach]:
 → Completed [afterEach].

FAILED: 1 assertions failed (11.74s)
bug help wanted stale

All 4 comments

Yes, it doesn't pick the xpath as the locating strategy, as it is clear by looking at the output:

Request POST  /wd/hub/session/0059af23f9df03127d897b001a311ffe/elements  
   { using: 'css selector', value: 'xpath' }

The problematic code is in here or here and a test can be added in test/src/api/commands/testWaitForElementVisible.js in case someone wants to give this a try.

This issue has been automatically marked as stale because it has not had any recent activity.
If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.

Got similar issue. I've created a Page Object with element like
SOME_ELEMENT : { locateStrategy: 'xpath', selector: '(//div[@class=\'modal-body\']/strong)' }
When I use in code for eg .click('@SOME_ELEMENT') it works ok, but when using assert.visible it is unable to locate the element unless I use .useXpath().....

This is still an issue on nightwatch version: 1.3.4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lgaticaq picture lgaticaq  Â·  3Comments

chaseconey picture chaseconey  Â·  4Comments

maxgalbu picture maxgalbu  Â·  3Comments

gary5 picture gary5  Â·  4Comments

antogyn picture antogyn  Â·  4Comments