I have a linux box and I am trying to run selenium tests (written in nightwatch) on it. I installed the chromedriver at http://chromedriver.storage.googleapis.com/index.html?path=2.9/ (the linuxx64 bit one)
I also installed the standalone selenium jar
I run the following command
DISPLAY=:1 xvfb-run java -jar lib/selenium-server-standalone-2.52.0.jar -Dwebdriver.chrome.driver=lib/chromedriver
Here's my nightwatch configuration:
{
"src_folders": [
"tests"
],
"output_folder": "reports",
"custom_commands_path": "custom_commands",
"custom_assertions_path": "",
"page_objects_path": "",
"live_output" : true,
"globals_path": "globals.js",
"selenium": {
"start_process": true,
"server_path": "lib/selenium-server-standalone-2.52.0.jar",
"log_path": "",
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver": "lib/chromedriver",
"webdriver.chromeJenkins.driver": "../../tools/chromedriver/chromedriver",
"webdriver.ie.driver": "lib/IEDriverServer_x64_2.52.2.exe",
"trustAllSSLCertificates": true
}
},
"test_workers": {
"enabled": true,
"workers": "auto"
},
"test_settings": {
"default": {
"launch_url": "",
"selenium_port": 4444,
"selenium_host": "localhost",
"silent": true,
"screenshots": {
"enabled": true,
"on_failure": true,
"on_error": true,
"path": "./screenshots"
},
"end_session_on_fail": false,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": [
"use-fake-device-for-media-stream",
"use-fake-ui-for-media-stream"
]
}
}
},
"jenkins" : {
"selenium_port" : 4444,
"selenium_host" : "127.0.0.1",
"cli_args" : {
"webdriver.chrome.driver" : "lib/chromedriver"
},
"chromeOptions" : {
"args" : ["--no-sandbox"]
},
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"platform" : "LINUX",
"chromeOptions" : {
"args" : ["--no-sandbox"]
}
}
}
}
Then I run the following command
DISPLAY=:1 xvfb-run --server-args="-screen 0, 1366x768x24" ./nightwatch -e jenkins --test tests/blog.js
The tests start to run, but when I look at the output the driver gets stuck at a particular element. It tries to find the element but times out. When I run the tests on my local machine, I do not get this error.
Am I doing something wrong here?
Check your browser viewport size. It's probably smaller in xvfb than it is on your main screen, and the site your testing may change behavior at different resolutions. Saw that my first day.
TL;DR My chrome window was the same size, but opening the debugging pane changed site behavior.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.