Closed phsultan closed 5 years ago
Where is Safari running?
A Safari instance is popped on the same computer I'm running the test command.
then you can remove "default_path_prefix": "/wd/hub"
and also the selenium
block just for testing in Safari.
The thing is that if I remove "default_path_prefix": "/wd/hub"
, then I hit https://github.com/nightwatchjs/nightwatch/issues/1943 (which applies both locally in my case and for BrowserStack).
So maybe you can post your config on #1943 so I can reproduce it? From your config posted here, there is no information about the selenium server.
In your safari
settings you can overwrite default_path_prefix
:
"safari": {
"webdriver": {
"default_path_prefix" : ""
},
"desiredCapabilities": {
"browserName": "safari",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
Sure, Selenium is started with:
$ java -Dwebdriver.chrome.driver='./node_modules/chromedriver/lib/chromedriver/chromedriver' -Dwebdriver.gecko.driver='./node_modules/geckodriver/geckodriver' -jar ./node_modulesium-server/lib/runner/selenium-server-standalone-3.14.0.jar -role standalone --debug
I had indeed post my environment details there (config, test command, selenium server command) : https://github.com/nightwatchjs/nightwatch/issues/1943#issuecomment-447849951
The difference is that I added the "default_path_prefix": "/wd/hub"
to work around https://github.com/nightwatchjs/nightwatch/issues/1943.
Thanks a lot for your help so far!
@phsultan I'm also wondering why you're starting Selenium separately and not through Nightwatch, since it is on the same machine?
That's because for some reason, when I started using Nightwatch + Selenium few months ago, I would randomly encounter this issue:
$ ./node_modules/nightwatch/bin/nightwatch --verbose
Starting Selenium Server on port 4444...
connect ECONNREFUSED 127.0.0.1:4444
socket hang up
at createHangUpError (_http_client.js:331:15)
at Socket.socketCloseListener (_http_client.js:363:23)
And having Selenium running in a separate process had fixed this totally.
Hmm, ok, was that in v1.0?
Most probably, yes. Launching Selenium from Nightwatch fixes this issue:
$ ./node_modules/nightwatch/bin/nightwatch --test sites/www.google.com.js --env safari --verbose
Starting Selenium Server on port 4444...
Selenium Server up and running on port 4444 with pid: 9739 (1025ms).
[Sites/Www Google Com] Test Suite
=================================
Request POST /wd/hub/session
{ desiredCapabilities:
{ browserName: 'safari',
acceptSslCerts: true,
platform: 'ANY',
javascriptEnabled: true,
name: 'Sites/Www Google Com' } }
Response 200 POST /wd/hub/session (2509ms)
{ status: 0,
sessionId: '0DCBA705-0D28-4868-BA46-DD3C24E3E2FB',
value:
{ browserVersion: '12.0.1',
platformName: 'macOS',
acceptInsecureCerts: false,
setWindowRect: true,
browserName: 'Safari',
'webdriver.remote.sessionid': '0DCBA705-0D28-4868-BA46-DD3C24E3E2FB' } }
Received session with ID: 0DCBA705-0D28-4868-BA46-DD3C24E3E2FB
→ Running [before]:
→ Completed [before].
Running: Google's Search Functionality
→ Running [beforeEach]:
→ Completed [beforeEach].
→ Running command: url ('https://www.google.com/ncr')
Request POST /wd/hub/session/0DCBA705-0D28-4868-BA46-DD3C24E3E2FB/url
{ url: 'https://www.google.com/ncr' }
Response 200 POST /wd/hub/session/0DCBA705-0D28-4868-BA46-DD3C24E3E2FB/url (1812ms)
{ state: 'success', sessionId: null, value: null, status: 0 }
→ Completed command url ('https://www.google.com/ncr') (1814ms)
→ Running command: waitForElementVisible ('body', 5000)
Request POST /wd/hub/session/0DCBA705-0D28-4868-BA46-DD3C24E3E2FB/elements
{ using: 'css selector', value: 'body' }
Response 200 POST /wd/hub/session/0DCBA705-0D28-4868-BA46-DD3C24E3E2FB/elements (15ms)
{ state: 'success',
sessionId: null,
value:
[ { 'element-6066-11e4-a52e-4f735466cecf': 'node-3596395C-AC34-4E7E-A8B7-EEAF8169D2A9' } ],
status: 0 }
Request GET /wd/hub/session/0DCBA705-0D28-4868-BA46-DD3C24E3E2FB/element/node-3596395C-AC34-4E7E-A8B7-EEAF8169D2A9/displayed
Response 200 GET /wd/hub/session/0DCBA705-0D28-4868-BA46-DD3C24E3E2FB/element/node-3596395C-AC34-4E7E-A8B7-EEAF8169D2A9/displayed (50ms)
{ state: 'success', sessionId: null, value: true, status: 0 }
✔ Element <body> was visible after 66 milliseconds.
→ Completed command waitForElementVisible ('body', 5000) (68ms)
Configuration is now:
{
"src_folders": [
"sites"
],
"output_folder": "reports",
"selenium" : {
"start_process": true,
"host": "localhost",
"server_path": "./node_modules/selenium-server/lib/runner/selenium-server-standalone-3.14.0.jar",
"cli_args": {
"webdriver.gecko.driver": "./node_modules/geckodriver/geckodriver",
"webdriver.chrome.driver": "./node_modules/chromedriver/lib/chromedriver/chromedriver"
}
},
"test_settings": {
"safari": {
"desiredCapabilities": {
"browserName": "safari",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"nativeEvents": true,
"chromeOptions": {
"args": [
"headless",
"no-sandbox",
"allow-file-access-from-files",
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream",
"disable-translate",
"no-process-singleton-dialog",
"mute-audio"
]
}
}
},
"firefox": {
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true,
"nativeEvents": true,
"moz:firefoxOptions": {
"log": {
"level": "trace"
},
"args": [
"-headless",
"-no-remote"
],
"prefs": {
"browser.cache.disk.enable": false,
"browser.cache.disk.capacity": 0,
"browser.cache.disk.smart_size.enabled": false,
"browser.cache.disk.smart_size.first_run": false,
"browser.sessionstore.resume_from_crash": false,
"browser.startup.page": 0,
"media.navigator.streams.fake": true,
"media.navigator.permission.disabled": true,
"device.storage.enabled": false,
"media.gstreamer.enabled": false,
"browser.startup.homepage": "about:blank",
"browser.startup.firstrunSkipsHomepage": false,
"extensions.update.enabled": false,
"app.update.enabled": false,
"network.http.use-cache": false,
"browser.shell.checkDefaultBrowser": false
}
}
}
}
}
}
Thanks a lot for your valuable help!
No problem, just so you know you can use ChromeDriver directly, without Selenium. I'm not entirely sure about GeckoDriver compatibility, but it is also possible to be used directly.
Yes, this discussion made me realize this too. Thank you.
Hi,
I'm running a simple test (against standalone selenium server at version 3.14.0) that fails at
waitForElementVisible()
:Command:
Checking out
tags/v1.0.14
and running the same command results in success:Configuration:
Let me know if you need more information!