You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When browser.waitForElementVisible()/waitForElementPresent() fail inside a custom command, Nightwatch process aborts with an unhandledRejection error.
Steps to reproduce
Init Nightwatch with cucumber.js and chromedriver
define a custom command containing a .waitForElementVisible() step
define a cucumber step that calls the custom command
pass a non-existent selector
Nightwatch returns a unhandledRejection error, the process terminates and the browser stays open
Sample test
// features/test.feature
Feature: loadwiki
Scenario: CheckthehomepageGivenInavigatetothehomepageThenanelementonthehomepageisvisible// customCommands/customWait.jsmodule.exports=classcustomWait{asynccommand(selector){awaitbrowser.waitForElementVisible(selector)}}// stepDefinitions/nightwatch.jsconst{ Given, Then }=require('@cucumber/cucumber')Given(/^I navigate to the homepage$/,asyncfunction(){awaitbrowser.navigateTo('https://en.wikipedia.org/wiki/Main_Page')})Then(/^an element on the homepage is visible$/,asyncfunction(){awaitbrowser.customWait('#mp-tfa-h2_ERROR')// non-existent selector})
Command to run
npx nightwatch --verbose
Verbose Output
⠋ Starting ChromeDriver on port 9515...
Starting ChromeDriver with server_path=C:\Users\Public\nightwatch\node_modules\chromedriver\lib\chromedriver\chromedriver.exe...
Request POST /session
{
capabilities: {
firstMatch: [ {} ],
alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': {} }
}
⠼ Starting ChromeDriver on port 9515...
⠇ Starting ChromeDriver on port 9515...
Response 200 POST /session (782ms)
{
value: {
capabilities: {
acceptInsecureCerts: false,
browserName: 'chrome',
browserVersion: '108.0.5359.125',
chrome: {
chromedriverVersion: '108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359@{#1016})',
userDataDir: 'C:\\Users\\SAVERI~1.CUT\\AppData\\Local\\Temp\\scoped_dir1016_1541866121'
},
'goog:chromeOptions': { debuggerAddress: 'localhost:53913' },
networkConnectionEnabled: false,
pageLoadStrategy: 'normal',
platformName: 'windows',
proxy: {},
setWindowRect: true,
strictFileInteractability: false,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
unhandledPromptBehavior: 'dismiss and notify',
'webauthn:extension:credBlob': true,
'webauthn:extension:largeBlob': true,
'webauthn:virtualAuthenticators': true
},
sessionId: '42b25824715f3e4c43c318c4f93d4bc6'
}
ℹ Connected to ChromeDriver on port 9515 (888ms).
Using: chrome (108.0.5359.125) on WINDOWS.
Received session with ID: 42b25824715f3e4c43c318c4f93d4bc6
.
→ Running command: navigateTo ('https://en.wikipedia.org/wiki/Main_Page')
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/url
{ url: 'https://en.wikipedia.org/wiki/Main_Page' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/url (1011ms)
{ value: null }
→ Completed command: navigateTo ('https://en.wikipedia.org/wiki/Main_Page') (1015ms)
.
→ Running command: customWait ('#mp-tfa-h2_ERROR')
→ Running command: waitForElementVisible ('#mp-tfa-h2_ERROR')
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (29ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (6ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (9ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (9ms)
{ value: [] }
[8708:9960:0103/112055.797:ERROR:device_event_log_impl.cc(215)] [11:20:55.796] USB: usb_device_handle_win.cc:1045 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
[8708:9960:0103/112055.797:ERROR:device_event_log_impl.cc(215)] [11:20:55.797] USB: usb_device_handle_win.cc:1045 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (9ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (7ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (8ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (8ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (8ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (9ms)
{ value: [] }
Request POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements
{ using: 'css selector', value: '#mp-tfa-h2_ERROR' }
Response 200 POST /session/42b25824715f3e4c43c318c4f93d4bc6/elements (10ms)
{ value: [] }
✖ NightwatchAssertError
Timed out while waiting for element <#mp-tfa-h2_ERROR> to be present for 5000 milliseconds. - expected "visible" but got: "not found" (5210ms)
Error location:
C:\Users\Public\nightwatch\customCommands\customWait.js:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
1 | module.exports = class customWait {
2 | async command(selector) {
3 | await browser.waitForElementVisible(selector)
4 | }
5 | }
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––
→ Completed command: waitForElementVisible ('#mp-tfa-h2_ERROR') (5217ms)
→ Completed command: customWait ('#mp-tfa-h2_ERROR') (5222ms)
Error
unhandledRejection: Timed out while waiting for element <#mp-tfa-h2_ERROR> to be present for 5000 milliseconds. - expected "visible" but got: "not found" (5210ms)
at World.<anonymous> (C:\Users\Public\nightwatch\stepDefinitions\nightwatch.js:8:17)
at Object.run (C:\Users\Public\nightwatch\node_modules\@cucumber\cucumber\lib\user_code_runner.js:24:27)
at Object.run (C:\Users\Public\nightwatch\node_modules\@cucumber\cucumber\lib\runtime\step_runner.js:52:59)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TestCaseRunner.invokeStep (C:\Users\Public\nightwatch\node_modules\@cucumber\cucumber\lib\runtime\test_case_runner.js:94:16)
at async TestCaseRunner.runStep (C:\Users\Public\nightwatch\node_modules\@cucumber\cucumber\lib\runtime\test_case_runner.js:243:26)
at async C:\Users\Public\nightwatch\node_modules\@cucumber\cucumber\lib\runtime\test_case_runner.js:174:44
at async TestCaseRunner.aroundTestStep (C:\Users\Public\nightwatch\node_modules\@cucumber\cucumber\lib\runtime\test_case_runner.js:119:32)
at async TestCaseRunner.runAttempt (C:\Users\Public\nightwatch\node_modules\@cucumber\cucumber\lib\runtime\test_case_runner.js:157:13)
at async TestCaseRunner.run (C:\Users\Public\nightwatch\node_modules\@cucumber\cucumber\lib\runtime\test_case_runner.js:135:35)
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
️TEST FAILURE (8.218s):
- 1 error during execution;
- 0 tests failed;
- 0/NA tests passed
@memihai This is the issue we encountered, I thought you might be interested.
asos-saveriocutrupi
changed the title
Nightwatch + Cucumber.js, waitFor-type commands fail when executed inside a custom command
Nightwatch + Cucumber.js, waitFor-type commands abort execution when failing inside a custom command
Jan 3, 2023
This error is still a blocker for us too and reproduces in the last Nightwatch version (2.6.8). It's blocking our migration from 0.9 to 2.6 in an extensive framework.
I was able to reproduce it using waitForElementVisible nested in custom commands or chai expect (browser.expect.element(xpath).to.be.visible) type of statements which I presume use waitForElementVisible underneath anyway.
@gravityvi I applied the fix from your commit on my local instance and the problem seems to have gone away. Thanks!
I have other problems now with my migration, but the problem described here seems to be behind us :).
Description of the bug/issue
Cucumber 8.10.0, Chromedriver 108.0.0.
When browser.waitForElementVisible()/waitForElementPresent() fail inside a custom command, Nightwatch process aborts with an unhandledRejection error.
Steps to reproduce
unhandledRejection
error, the process terminates and the browser stays openSample test
Command to run
Verbose Output
Nightwatch Configuration
Nightwatch.js Version
2.6.4
Node Version
18.4.0
Browser
Chrome Version 108.0.5359.125
Operating System
Windows 10 Enterprise
Additional Information
No response
The text was updated successfully, but these errors were encountered: