Closed rkhaneds closed 2 years ago
Try setting w3c: false.
We tried with w3c: false in chrome options but still getting the same error. Please note we get error in Firefox as well.
Testing if element <input[name="q"]> is visible in 10000ms - expected "is visible" but got: "element could not be located"
Issue happens in our hosted grid in open stack.
Test runs fine in locally created grid if started from nightwatch (i.e. selenium: { start_process: true, server_path: require('selenium-server').path,...}) (
@beatfactor can we please get help on this, we got stuck and can't move forward. Please check and do the needful.
@beatfactor any guidence for us will be really helpful.
@beatfactor we are facing the same issue as well. We tried using w3c:fasle as per your recommendations for chromeoptions, firefoxoptions and safarioptions and still we are having issues with basic commands like
We did some further investigation to try and pinpoint where the problem resides and our findings are shown below. This consisted of executing a simple Nightwatch script against different versions of Selenium Servers/Selenium Grids. When trying different versions of Selenium Server we saw some improvement for some of the problems that are occurring. In some cases Nightwatch interacts with some browsers better than on other versions of Selenium Server but there doesn't appear to be a version of Selenium Server that will overcome enough of the compatibility issues
Please note: We have tested the sample example shown below on both Local selenium server and also on a docker container(Linux, chrome, firefox).
Nightwatch version: 1.5.1 Example: Sample test module.exports = { 'Search google': function (browser) { browser .url('http://www.google.com') .waitForElementPresent('input[name="q"]') .waitForElementVisible('input[name="q"]') .sendKeys('input[name="q"]', 'nightwatch') .assert.containsText('.g .rc', 'Nightwatch.js') .end(); } }
Nightwatch.conf.js chrome: { desiredCapabilities: { browserName: "chrome", chromeOptions: { w3c: false } } }, firefox: { desiredCapabilities: { browserName: "firefox", platformName: "MAC", firefoxOptions: { w3c: false } } }
Outcome:
Nightwatch version | Selenium Server/Grid Version | Web Browser | Web Browser Version | Nightwatch | Notes |
---|---|---|---|---|---|
1.5.1 | 3.0.1 | Chrome | 87 | YES | No issues with the latest browser. |
1.5.1 | 3.0.1 | Firefox | 83 | YES | No issues with the latest browser. |
1.5.1 | 3.0.1 | Safari | 14.0.0 | YES | |
1.5.1 | 3.0.1 | Safari | 14.0.1 | NO | Post browser update, Safari 14.0.1 does not work with NightWatch 1.5.1 |
1.5.1 | 3.14.0 | Chrome | 87 | NO | Test fails with a time out since its not able to do the basic check of element visible and even basic commands like input text and submit clicks fail with a timeout |
1.5.1 | 3.14.0 | Firefox | 83 | NO | Test fails with a time out since its not able to do the basic check of element visible and even basic commands like input text and submit clicks fail with a timeout |
1.5.1 | 3.14.0 | Safari | 14.0.1 | NO | Test fails with a time out since its not able to do the basic check of element visible and even basic commands like input text and submit clicks fail with a timeout |
1.5.1 | 3.141.0 | Chrome | 87 | NO | Test fails with a time out since its not able to do the basic check of element visible and even basic commands like input text and submit clicks fail with a timeout |
1.5.1 | 3.141.0 | Firefox | 83 | NO | Test fails with a time out since its not able to do the basic check of element visible and even basic commands like input text and submit clicks fail with a timeout |
1.5.1 | 3.141.0 | Safari | 14.0.1 | NO | Test fails with a time out since its not able to do the basic check of element visible and even basic commands like input text and submit clicks fail with a timeout |
1.5.1 | 3.141.59 (latest stable release) | Chrome | 87 | YES | No issues with the latest browser. May encounter issues when test with different versions of the same browsers |
1.5.1 | 3.141.59 (latest stable release) | Firefox | 83 | NO | Test fails with a time out since its not able to do the basic check of element visible and even basic commands like input text and submit clicks fail with a timeout |
1.5.1 | 3.141.59 (latest stable release) | Safari | 14.0.1 | NO | Test fails with a time out since its not able to do the basic check of element visible and even basic commands like input text and submit clicks fail with a timeout |
1.5.1 | 4.0.0-alpha-7 (new alpha release) | Chrome | 87 | NO | Few commands work such as Input text and Clicking on Submit buttons, but command to check if element is visible(waitForElementVisible) & other Nightwatch native commands return 500 error. |
1.5.1 | 4.0.0-alpha-7 (new alpha release) | Firefox | 83 | NO | Few commands work such as Input text and Clicking on Submit buttons, but command to check if element is visible(waitForElementVisible) & other Nightwatch native commands return 500 error. |
1.5.1 | 4.0.0-alpha-7 (new alpha release) | Safari | 14.0.1 | NO | Few commands work such as Input text and Clicking on Submit buttons, but command to check if element is visible(waitForElementVisible) & other Nightwatch native commands return 500 error. |
Any help/guidance would be greatly appreciated
running into a similar error on nightwatch 1.5.1 when running selenium grid 3 + chrome on fargate. Ours occurs broadly for things like .waitForElementPresent('body')
or .waitForElementPresent('head')
. I expect its a config issue between your browser setup and nightwatch capabilities config.
FWIW- I haven't gotten it to work but my research is as follows:
referenced issue: https://github.com/nightwatchjs/nightwatch/issues/2414
Others suggest to set chromeOptions w3c = false and args as follows:
//good explanation in readme: https://github.com/taktakpeops/selenium-grid-ecs-fargate
chromeOptions: {
w3c: false,
args: ['no-sandbox', 'disable-setuid-sandbox', 'headless', 'whitelist-ips', 'disable-dev-shm-usage']
},
from: https://github.com/SeleniumHQ/selenium/issues/7476#issuecomment-519938952 In chromedriver 75+ you are expected to pass goog:chromeOptions as the key as chromeOptions itself is not w3c compliant. Instead if you w3c = false it is allowed chromeOptions.
Although, I attempted to pass both as received an error when passing goog:chromeOptions. It also does not appear like these settings were correctly applying to my session/ nightwatch correctly doing the config. I am still investigating but will post once I have solution.
EDITED: was able to get it working by adding this in nightwatch.conf.js:
['goog:chromeOptions']: {
w3c: false,
args: ['no-sandbox', 'disable-setuid-sandbox', 'headless', 'whitelist-ips', 'disable-dev-shm-usage']
},
Thanks for the follow up @leetmachine
I have some follow up questions:
@leetmachine: Your are awesome!!!
@beatfactor: Since you are a maintainer....why must w3c
be set to false
? The official Nightwatch.js docs claims that it uses the W3C WebDriver API
.... Does it have anything to do with the usage of custom commands?
Any additional insights into the issue would help for the development of tests in the future.... We intend to use Nightwatch.js a lot and want to be as up to date and as compliant with modern standards as possible.
@rkhaneds Were you able to solve your issue with the solution introduced by @leetmachine ?
If you are using docker selenium grid you can try updating it to version 4, that solved the issue for me. Selenium grid 3 will be deprecated soon anyway. Note: If you use :latest docker will install version 3 still , you need to specify the version 4 for installation. Hope this is helpful to you too.
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.
Describe the bug
Timed out while waiting for element to be present for 10000 milliseconds. - expected "visible" but got: "not found"
Sample test
module.exports = { 'Search google': function (browser) { browser .url('http://google.co.in/') .assert.titleContains('Google') .assert.visible('input[name="q"]') .sendKeys('input[name="q"]', 'nightwatch\n') .assert.containsText('.g .rc', 'Nightwatch.js') .end(); } }
Run with command npx nightwatch -e hostedGrid tests\search\google.js
Verbose output
D:\git\functional-tests\nightwatchjs-tests>npx nightwatch -e hostedGrid tests\search\google.js --verbose [Search\google] Test Suite
Connecting to 10.240.8.73 on port 4444... Request POST http://10.240.8.73:4444 /wd/hub/session
{ desiredCapabilities: { browserName: 'chrome', platform: 'ANY', chromeOptions: { args: [ 'start-maximized' ] }, name: 'Search\google' } | Connecting to 10.240.8.73 on port 4444... Response 200 POST http://10.240.8.73:4444/wd/hub/session (872ms) { value: { sessionId: '04aee5a2fc2cd202cb453c08108319bb', capabilities: { acceptInsecureCerts: false, browserName: 'chrome', browserVersion: '86.0.4240.75', chrome: { chromedriverVersion: '86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378})', userDataDir: '/tmp/.com.google.Chrome.5IafuS' }, 'goog:chromeOptions': { debuggerAddress: 'localhost:34750' }, networkConnectionEnabled: false, pageLoadStrategy: 'normal', platformName: 'linux', proxy: {}, setWindowRect: true, strictFileInteractability: false, timeouts: { implicit: 0, pageLoad: 300000, script: 30000 }, unhandledPromptBehavior: 'dismiss and notify', 'webauthn:virtualAuthenticators': true, 'webdriver.remote.sessionid': '04aee5a2fc2cd202cb453c08108319bb' } } i Connected to 10.240.8.73 on port 4444 (929ms). Using: chrome (86.0.4240.75) on linux platform. Received session with ID: 04aee5a2fc2cd202cb453c08108319bb → Running [before]: → Completed [before]. Running: Search google → Running [beforeEach]: → Completed [beforeEach]. → Running command: url ('http://google.co.in/') Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/url { url: 'http://google.co.in/' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/url (1534ms) { value: null } → Completed command: url ('http://google.co.in/') (1546ms) → Running command: assert.titleContains ('Google') → Running command: title ([Function]) Request GET http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/title Response 200 GET http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/title (610ms) { value: 'Google' } √ Testing if the page title contains 'Google' (615ms) → Completed command: assert.titleContains ('Google') (618ms) → Running command: assert.visible ('input[name="q"]')
→ Completed command: title ([Function]) (616ms) → Running command: isVisible ('input[name="q"]', [Function]) Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (613ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (611ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (612ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (621ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (611ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (608ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (612ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (615ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } Request POST http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements
{ using: 'css selector', value: 'input[name="q"]' } Response 200 POST http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb/elements (1627ms) { value: [ { 'element-6066-11e4-a52e-4f735466cecf': 'c8f93d88-8d85-40bc-8da4-2121171853cd' } ] } × Testing if element <input[name="q"]> is visible in 10000ms - expected "is visible" but got: "element could not be located" (10692ms) at Object.Search google (D:\git\functional-tests\nightwatchjs-tests\tests\search\google.js:6:15) at processTicksAndRejections (internal/process/task_queues.js:97:5) → Completed command: isVisible ('input[name="q"]', [Function]) (10687ms) → Completed command: assert.visible ('input[name="q"]') (10696ms) → Running [afterEach]: → Completed [afterEach]. FAILED: 1 assertions failed, 1 errors and 1 passed (12.866s) → Running [after]: → Completed [after]. → Running command: end ()
→ Running command: session ('delete', [Function]) Request DELETE http://10.240.8.73:4444 /wd/hub/session/04aee5a2fc2cd202cb453c08108319bb
Response 200 DELETE http://10.240.8.73:4444/wd/hub/session/04aee5a2fc2cd202cb453c08108319bb (658ms) { value: null } → Completed command: end () (664ms) → Completed command: session ('delete', [Function]) (660ms)
TEST FAILURE: 1 error during execution; 1 assertions failed, 1 passed (14.602s) × search\google – Search google (12.866s) Testing if element <input[name="q"]> is visible in 10000ms - expected "is visible" but got: "element could not be located" (10692ms) at Object.Search google (D:\git\functional-tests\nightwatchjs-tests\tests\search\google.js:6:15) at processTicksAndRejections (internal/process/task_queues.js:97:5) NoSuchElementError: An error occurred while running .isVisible() command on <input[name="q"]>: {"value":[{"element-6066-11e4-a52e-4f735466cecf":"c8f93d88-8d85-40bc-8da4-2121171853cd"}]} at processTicksAndRejections (internal/process/task_queues.js:97:5)
Configuration
module.exports = { src_folders: ["tests"], page_objects_path: ["page_objects"], globals_path: 'globals.js', test_workers: { enabled: true, workers: 4 }, test_settings: { default: { launch_url: 'http://google.com', webdriver: { start_process: true, port: 4444, server_path: require('chromedriver').path, }, desiredCapabilities: { browserName: 'chrome', chromeOptions: { args: [ "window-size=1280,800" ] } }, }, hostedGrid: { launch_url: 'http://google.com', selenium: { start_process: false, port: 4444, host: "10.240.8.73", }, webdriver: { start_process: false, keep_alive: true, timeout_options: { timeout: 60000, retry_attempts: 3 } }, desiredCapabilities: { browserName: 'chrome', chromeOptions: { args: [ "start-maximized" ] }, } } } } Collapse
nightwatch --version
npm --version
node --version