nightwatch version: v1.0.18
When running a minimal test:
.url('https://google.com')
.waitForElementPresent('body', 5000)
.end();
, it will get stuck waiting for the element.
I don't know what changed between the different selenium protocol versions, so I don't know exactly what is wrong, but this is what I observed:
the /elements to chrome (working, protocol v2) returns:
{ sessionId: 'c5c31eabee990ae1e783cb1c46b0fbe2',
status: 0,
value: [ { ELEMENT: '0.7236664760673073-1' } ] }
the /elements to firefox (not working, protocol v3) returns:
{ value:
[ { 'element-6066-11e4-a52e-4f735466cecf': 'ac375d8f-d8a8-4b21-b525-fe3d2b51afaa' } ] }
It looks like jsonwire#isResultSuccess expects the status field, no matter which protocol version. Is that right?
It's very possible that this issue lies somewhere else (configuration, selenium hub), but I know too little to say for sure.
I tried to create a small repro environment, but there's quite a lot of config anyway:
Stock selenium hub docker images:
version: "2"
services:
selenium-hub:
image: selenium/hub:3.141.59-gold
container_name: selenium-hub
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome-debug:3.141.59-gold
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
firefox:
image: selenium/node-firefox-debug:3.141.59-gold
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
Nightwatch config:
{
"src_folders": ["tests"],
"selenium": {
"start_process": false,
"log_path": "",
"port": 4444,
"default_path_prefix": "/wd/hub",
"host": "localhost"
},
"test_settings": {
"default": {
"desiredCapabilities": {
"browserName": "firefox"
}
}
}
}
Log output:
[Test] Test Suite
=================
Request POST /wd/hub/session
{ desiredCapabilities:
{ browserName: 'firefox',
acceptSslCerts: true,
platform: 'ANY',
name: 'Test' } }
Response 200 POST /wd/hub/session (1315ms)
{ value:
{ sessionId: '383a8206-bfee-4790-a015-b99ab56b5680',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '65.0',
'moz:accessibilityChecks': false,
'moz:geckodriverVersion': '0.24.0',
'moz:headless': false,
'moz:processID': 119,
'moz:profile': '/tmp/rust_mozprofile.qyiBDSAdnBR3',
'moz:shutdownTimeout': 60000,
'moz:useNonSpecCompliantPointerOrigin': false,
'moz:webdriverClick': true,
pageLoadStrategy: 'normal',
platformName: 'linux',
platformVersion: '4.4.0-142-generic',
rotatable: false,
setWindowRect: true,
strictFileInteractability: false,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 },
unhandledPromptBehavior: 'dismiss and notify',
'webdriver.remote.sessionid': '383a8206-bfee-4790-a015-b99ab56b5680' } } }
Received session with ID: 383a8206-bfee-4790-a015-b99ab56b5680
→ Running [before]:
→ Completed [before].
Running: Demo test
→ Running [beforeEach]:
→ Completed [beforeEach].
→ Running command: url ('https://google.com')
Request POST /wd/hub/session/383a8206-bfee-4790-a015-b99ab56b5680/url
{ url: 'https://google.com' }
Response 200 POST /wd/hub/session/383a8206-bfee-4790-a015-b99ab56b5680/url (668ms)
{ value: null }
→ Completed command url ('https://google.com') (668ms)
→ Running command: waitForElementPresent ('body', 5000)
Request POST /wd/hub/session/383a8206-bfee-4790-a015-b99ab56b5680/elements
{ using: 'css selector', value: 'body' }
Response 200 POST /wd/hub/session/383a8206-bfee-4790-a015-b99ab56b5680/elements (21ms)
{ value:
[ { 'element-6066-11e4-a52e-4f735466cecf': 'ac375d8f-d8a8-4b21-b525-fe3d2b51afaa' } ] }
Request POST /wd/hub/session/383a8206-bfee-4790-a015-b99ab56b5680/elements
{ using: 'css selector', value: 'body' }
Response 200 POST /wd/hub/session/383a8206-bfee-4790-a015-b99ab56b5680/elements (13ms)
{ value:
[ { 'element-6066-11e4-a52e-4f735466cecf': 'ac375d8f-d8a8-4b21-b525-fe3d2b51afaa' } ] }
Request POST /wd/hub/session/383a8206-bfee-4790-a015-b99ab56b5680/elements
{ using: 'css selector', value: 'body' }
Response 200 POST /wd/hub/session/383a8206-bfee-4790-a015-b99ab56b5680/elements (14ms)
{ value:
[ { 'element-6066-11e4-a52e-4f735466cecf': 'ac375d8f-d8a8-4b21-b525-fe3d2b51afaa' } ] }
.... (same request - response messages repeating until it times out)
works only on chrome for me. all the other browsers timeout.
Similar issues with Firefox on Browserstack. Here is what one of their support agents replied to me:
Selenium 4 is going to launch soon. The Selenium 4 WebDriver will be completely W3C Standardized. With W3C standardized the capabilities format is getting changed and capabilities names which do not follow W3C specifications can result in an error In order to make sure that your tests do not break and minimal changes are required at your end, we have started mapping the capabilities to W3C compliant format.
Before updating the respective changes there was a detailed session analysis was conducted which consisted of various parameters (target language, region, etc). The number of users that will be affected are on the lower end. I confirm that the users with WebDriverIO, NightwatchJS, and InternJS are facing similar behavior (which was anticipated).
In the shared session, the Firefox browser is strictly following the W3C mode. However, the language-bindings at your end are forwarding the command in OSS format.
Since the browser is running in W3C mode, it could not understand OSS endpoints. Hence the exceptions were thrown in the tests. You can view the list of valid W3C endpoints in the link below:
https://www.w3.org/TR/webdriver1/#list-of-endpoints
The team has been monitoring this behaviour and a constructive fix is underway. This fix will enable affected users to run the tests properly. The current ETA for this task is 7-FEB-2019. I will surely inform you once the fix is deployed.
So yeah, maybe it's related to what is mentioned there.
@jeececab , did you get any update from them?
@zndao Unfortunately still no news. I wrote back to them for an update, but it wasn't done yet. The support agent should normally get back to me once it's done. I'll post updates here.
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.
This issue has been automatically marked as stale because it has not had any recent activity.
This is still a problem. Semi-recent firefox versions + nightwatch 1 + selenium hub still seems to have a few compatibility problems.
Hi. I have exactly the same problem.
This is my code:
const linksOfNavbar = 'nav > a';
browser.elements('css selector', linksOfNavbar, function(result) {
console.log(result.value)
let dinamicSelector;
result.value.forEach((res) => {
browser.elementIdAttribute(res.ELEMENT, 'id', function(idValue) {
dinamicSelector = `#${idValue.value}`; // creating a dinamic selector of element through 'id' attribute value.
browser.expect.element(dinamicSelector).to.be.an('a', 'Testing if element is HTML tag: \'a\' (link)');
browser.expect.element(dinamicSelector).text.to.match(/.{1,}/); // contain some text
browser.expect.element(dinamicSelector).to.be.visible;
});
});
Using Chrome, the console.log return this:
[ { ELEMENT: '0.8639917139500535-2' },
{ ELEMENT: '0.8639917139500535-3' } ]
Using Firefox, the console.log return this:
[ { 'element-6066-11e4-a52e-4f735466cecf': 'c4994add-35ff-294a-a5d1-b433ba5b4249' },
{ 'element-6066-11e4-a52e-4f735466cecf': '5a2838da-2ae8-c948-bc98-1421e1e69581' } ]
I'm running Nightwatch using this command:
nightwatch --config e2e-tests/nightwatch.conf.js -e chrome,firefox
And this is my configuration:
const chromedriver = require('chromedriver');
const geckodriver = require('geckodriver');
module.exports = {
'src_folders': [
'./e2e-tests/tests/'// Where you are storing your Nightwatch e2e tests
],
'custom_commands_path': './e2e-tests/custom-commands/',
'output_folder': './e2e-tests/reports/', // reports (test outcome) output by nightwatch
'webdriver' : {
'start_process': true, // tells nightwatch to start/stop the process by itself
'server_path': chromedriver.path,
'host': '127.0.0.1',
'port': 9515,
'log_path' : './e2e-tests/logs-e2e/'
},
'test_workers': {
'enabled': false, // Set to true to allow run test in parallel. No compatible with execute test in more than one browser
'workers': 'auto'
},
'test_settings': {
'default': {
'webdriver': {
'server_path': chromedriver.path
},
'desiredCapabilities': { // use Chrome as the default browser for tests
'browserName': 'chrome'
}
},
'chrome': {
'webdriver' : {
'start_process': true, // tells nightwatch to start/stop the process by itself
'server_path': chromedriver.path,
'host': '127.0.0.1',
'port': 9515,
'log_path' : './e2e-tests/logs-e2e/'
},
'screenshots': {
'enabled': true, // if you want to keep screenshots
'path': './e2e-tests/screenshots/' // save screenshots here, but you can define it when you do the screenshot
},
'globals': {
'waitForConditionTimeout': 5000 // sometimes internet is slow so wait.
},
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true, // turn off to test progressive enhancement
'acceptInsecureCerts' : true
}
},
'firefox': {
'webdriver': {
'start_process': true, // tells nightwatch to start/stop the process by itself
'server_path': geckodriver.path,
'host': '127.0.0.1',
'port': 4444,
'cli_args': [
'--log', 'debug'
]
},
'screenshots': {
'enabled': true, // if you want to keep screenshots
'path': './e2e-tests/screenshots/' // save screenshots here, but you can define it when you do the screenshot
},
'globals': {
'waitForConditionTimeout': 5000 // sometimes internet is slow so wait.
},
'desiredCapabilities': {
'browserName': 'firefox',
'marionette': true,
'javascriptEnabled': true, // turn off to test progressive enhancement
'acceptInsecureCerts' : true
}
}
}
};
I am getting 'undefined' as the response.ELEMENT value in any browser.element() call in FF.
Hi @beaudamorevitas! Try using this approach:
'All navbar links should contain some text and be visible': function(browser) {
// example of iteration through DOM elements
browser.elements('css selector', linksOfNavbar, function(result) {
let dinamicSelector;
result.value.forEach((res) => {
const firstKey = 0;
const keyOfElement = Object.keys(res)[firstKey];
browser.elementIdAttribute(res[keyOfElement], 'id', function(idValue) {
dinamicSelector = `#${idValue.value}`; // creating a dinamic selector of element through 'id' attribute value.
browser.expect.element(dinamicSelector).to.be.an('a', 'Testing if element is HTML tag: \'a\' (link)');
browser.expect.element(dinamicSelector).text.to.match(/.{1,}/); // contain some text
browser.expect.element(dinamicSelector).to.be.visible;
});
});
});
}
This is compatibly with geckodriver and with chromedriver at the same time.
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.
Most helpful comment
Similar issues with Firefox on Browserstack. Here is what one of their support agents replied to me:
So yeah, maybe it's related to what is mentioned there.