We have many tests that make use of sections. Whenever one of these tests contains a call to verify an element within a section and the test fails, the correct error is reported, along with the allElements.shift is not a function error. Unfortunately, the final test summary at the end of the test run ONLY reports the allElements.shift error, instead of the correct, more helpful error that the element being sought was not available.
For example:
My test has the following line:
this.section.userMenu.expect.element('@logOff').to.be.visible
If the expectation fails when the test runs, I see:
✖ Expected element <Section[name=accountDropDown],Element[name=@signOut]> to be visible - expected "visible" but got: "not visible"
at Object.commands.assertLogoutButton (/app/e2e/pages/global.js:51:41)
at Object.module.exports.before.Throws an error for an incorrect login.Logs in with a valid user (/app/e2e/tests/login/login.spec.js:19:16)
The test then automatically retries. When this happens, an earlier validation (which occurs inside an iframe), which passed on the first attempt, now fails on the second attempt:
this.api.frame('login_iframe').waitForElementPresent('main_page_content')
Then, when the suite completes, that failure reports as:
TEST FAILURE: 1 error during execution, 0 assertions failed, 6 passed. (42.602s)
✖ login/login.spec
- Throws an error for an incorrect login (7.581s)
Error while running waitForElementPresent command: allElements.shift is not a function
at Object.setCredentialFields (/app/e2e/pages/login.js:63:8)
at Object.commands.loginFlow (/app/e2e/pages/login.js:40:10)
at Object.module.exports.before.Throws an error for an incorrect login (/app/e2e/tests/login/login.spec.js:13:15)
Summary:
see: https://github.com/nightwatchjs/nightwatch/issues/1100#issuecomment-235163142
We need to figure out where the locateStategy mixup is happening.
@magicclaw Do you have a complete example that demonstrates this issue?
I'm kind of hoping this problem just goes away after #1116 eventually gets in, since that implementation avoids the locate strategy set-then-reset steps with the callback wrapping in page objects.
I'm seeing this error in the retries after a command failure. Does anyone know if this is already fixed?
Retrying (1/7): Remembers the computer
✔ Testing if element <body> contains text: "cleared".
✔ Element <#content> was visible after 2846 milliseconds.
✔ Element <Section[name=loginForm],Element[name=@usernameField]> was visible after 489 milliseconds.
✖ Timed out while waiting for element <Section[name=twoFactorForm],Element[name=@tokenField]> to be present for 10000 milliseconds. - expected "visible" but got: "not found"
at Object.verify2fa (/home/tri/app/test/nightwatch/pageObjects/login.js:48:10)
at Object.Remembers the computer (/home/tri/app/test/nightwatch/login.js:114:8)
Retrying (2/7): Remembers the computer
Error while running getText command: allElements.shift is not a function
at command (/home/tri/app/node_modules/nightwatch/lib/api/assertions/containsText.js:46:21)
at module.exports.BaseAssertion._scheduleAssertion (/home/tri/app/node_modules/nightwatch/lib/core/assertion.js:87:17)
Should be fixed in v1.0.4.
Most helpful comment
I'm seeing this error in the retries after a command failure. Does anyone know if this is already fixed?