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 /main//header[1]/form/input> was visible after 2039 milliseconds.
browser.waitForElementVisible({
locateStrategy: 'xpath',
selector: '//main//header[1]/form/input'
});
Please include the following:
→ 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)
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