When I run an acceptance test on a remote linux server in Jenkins, the job fails
Facebook\WebDriver\Exception\SessionNotCreatedException] Unable to create new service: ChromeDriverService
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
Driver info: driver.version: unknown
I run the selenium server with the command
java -Dwebdriver.chrome.driver=./Codeception/chromedriver -jar ./Codeception/selenium-server-standalone-3.14.0.jar -port 17570 &
and run test
./composer.phar install
php codecept.phar run tests/acceptance/Jenkins_test_Cept.php --debug
Chrome version: 108.0.5359.124
Console log
+ java -Dwebdriver.chrome.driver=./Codeception/chromedriver -jar ./Codeception/selenium-
server-standalone-3.14.0.jar -port 17570
[workspace] $ /bin/sh -xe /tmp/***
+ cd Codeception/Brand_Analytics
+ ./composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.
Generating autoload files
+ php codecept.phar run tests/acceptance/Jenkins_test_Cept.php --debug
How I can solve this problem? I'm new in Jenkins and have no idea what to do
So I have been working in Protractor for my end to end tests of my Angular application. It has been working for as long as I have been developing the tests. Then most recently it gave me the below error. Originally I had thought it had to do with Chrome and Chromedriver not being compatible. So I went to update chrome and chromedriver that did not work for me. I then tried to install Chrome version 88 and its corresponding chromedriver and that produced the error still. So I would like to know what could the issue be with my dev environment.
[16:55:10] I/config_source - curl -o/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/protractor/node_modules/webdriver-manager/selenium/chrome-response.xml https://chromedriver.storage.googleapis.com/
ℹ 「wdm」: Compiled successfully.
[16:55:10] I/update - chromedriver: file exists /Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_87.0.4280.88.zip
[16:55:10] I/update - chromedriver: unzipping chromedriver_87.0.4280.88.zip
[16:55:10] I/update - chromedriver: setting permissions to 0755 for /Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_87.0.4280.88
[16:55:10] I/update - chromedriver: chromedriver_87.0.4280.88 up to date
[16:55:11] I/launcher - Running 1 instances of WebDriver
[16:55:11] I/direct - Using ChromeDriver directly...
[16:55:12] E/launcher - spawn Unknown system error -86
[16:55:12] E/launcher - Error: spawn Unknown system error -86
at ChildProcess.spawn (internal/child_process.js:407:11)
at Object.spawn (child_process.js:548:9)
at exec (/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/selenium-webdriver/io/exec.js:116:27)
at /Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/selenium-webdriver/remote/index.js:219:25
at processTicksAndRejections (internal/process/task_queues.js:97:5)
From: Task: WebDriver.createSession()
at Function.createSession (/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/selenium-webdriver/chrome.js:761:15)
at Direct.getNewDriver (/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/protractor/built/driverProviders/direct.js:77:33)
at Runner.createBrowser (/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/protractor/built/runner.js:195:43)
at /Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/protractor/built/runner.js:339:29
at _fulfilled (/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/q/q.js:834:54)
at /Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/q/q.js:796:13)
at /Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/q/q.js:556:49
at runSingle (/Users/gregoryrothstein/dev/sso_service/aicure-dashboard/node_modules/q/q.js:137:13)
[16:55:12] E/launcher - Process exited with error code 199
An unexpected error occurred: undefined
Versions:
Google Chrome: Version 88.0.4324.77 (Official Build) beta (x86_64)
Protractor: #7.0.0
webdriver-manager: #12.1.7
Solved in webdriver-manager#12.1.8
Make sure to install it globally and locally
Server: Raspberry Pi 3
OS: Dietpi - version 159
Geckodriver version: 0.22 for arm
Firefox version: 52.9.0
Python version: 3.5
Selenium version: 3.14.1
Gecko is executable, and is located in /usr/local/bin/
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.options import Options
import time
options = Options()
options.set_headless(headless=True)
driver = webdriver.Firefox(firefox_options=options)
print('Need your login credential')
username = input('What is your username?:\n')
password = input('What is your password?:\n')
...
...
Output:
root#RPi3:~# python3.5 ITE-bot.py
Traceback (most recent call last):
File "ITE-bot.py", line 12, in <module>
driver = webdriver.Firefox(firefox_options=options)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
Any idea what is wrong? I've tried google without luck.
If you are running Firefox on a system with no display, make sure you use headless mode.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
Also, make sure you have compatible versions of Firefox, Selenium, and Geckodriver:
https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html
Thumb rule
A common cause for Browsers to crash during startup is running WebDriver initiated Browsers as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Browser as a regular user instead.
This error message...
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process
...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowsing Session i.e. Firefox Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Your GeckoDriver version is 0.22.0.
Release Notes of GeckoDriver v0.21.0 (2018-06-15) clearly mentions the following:
Firefox 57 (and greater)
Selenium 3.11 (and greater)
Your Firefox version is 52.9.0.
So there is a clear mismatch between GeckoDriver v0.22.0 and the Firefox Browser v57
Solution
Upgrade GeckoDriver to GeckoDriver v0.22.0 level.
GeckoDriver is present in the specified location.
GeckoDriver is having executable permission for non-root users.
Upgrade Firefox version to Firefox v62.0.2 levels.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Execute your Selenium Test as a non-root user.
GeckoDriver, Selenium and Firefox Browser compatibility chart
I was on headless mode, using correct versions of everything, and the only way to get out of this error message was not to execute the selenium test as root
Yes checked Start Xvfb before the build can fix the problem, but if you have a job like a pipeline or multibranch pipeline this option is not visible. In the node of your Selenium grid that you go to execute the test you need:
1- Install Xvfb: apt install xvfb
2- Execute Xvfb: /usr/bin/Xvfb :99 -ac -screen 0 1024x768x8 & export DISPLAY=":99"
3- Rerun your node, for example: java -jar selenium.jar -role node -hub http://#.#.#.#:4444/grid/register -capabilities browserName=firefox,plataform=linux -host #.#.#.# -port 1991
This solution worked for me
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
As there can be many different underlying causes for this error it is best to find the root cause setting selenium to use debug level logging. In my case, for Ruby with capybara I needed to set: Selenium::WebDriver.logger.level = :debug. And voilà, running the same spec I could see in the logs that a dependency was missing, in my case:
libdbus-glib-1.so.2: cannot open shared object file: No such file or directory
Couldn't load XPCOM.
After installing it all worked fine.
I used:
VS Code
Linunx/Ubuntu:18.10
Nightwatch.js
My problem was that I tried to run Nightwatch (which automatically starts GeckoDriver) from the VS Code terminal.
I had the same problem, and realized that the real problem was some firefox dependencies not being installed inside the docker container I was testing in.
Try to initiate firefox and check if it returns an error.
As Nico and jay have stated you need to check the logs to see the details of the error. As you might use different systems, you can specify the path where the log is stored (i.e. "/tmp/geckodriver.log").
from selenium import webdriver
firefox_options = webdriver.firefox.webdriver.Options()
driver = webdriver.Firefox(log_path="/tmp/geckodriver.log",
options=firefox_options)
In my particular case, what the log said was:
Error: no DISPLAY environment variable specified
That was resolved adding in the options the headless mode before starting the driver. With the line:
firefox_options.set_headless()
I was able to fix this by running my tests with Xvfb. I was running them on a remote server.
I was using Jenkins so I checked the box that looked like this:
Credit to https://www.obeythetestinggoat.com/book/chapter_CI.html
in my case, I was running test cases as root
geckodriver.log
1576076416677 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilenCbl2e"
Running Firefox as root in a regular user's session is not supported. ($HOME is /home/seluser which is owned by seluser.)
1576077143004 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile7wpSQ7"
1576077143689 addons.webextension.screenshots#mozilla.org WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1576077143689 addons.webextension.screenshots#mozilla.org WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: telemetry
1576077143689 addons.webextension.screenshots#mozilla.org WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1576077143689 addons.webextension.screenshots#mozilla.org WARN Loading extension 'screenshots#mozilla.org': Reading manifest: Invalid extension permission: about:reader*
1576077145372 Marionette INFO Listening on port 35571
1576077145423 Marionette WARN TLS certificate errors will be ignored for this session
1576077200207 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofilenhoHlr"
Running Firefox as root in a regular user's session is not supported. ($HOME is /home/seluser which is owned by seluser.)
i could get around by
cd /home
chown -R root seluser
i woundnt say its correct but it got my job done
I'm using Selenium for testing from Java code, it's started automatically with maven, when I run mvn verify it uses gecko-driver to start new firefox instance for selenium:
final FirefoxOptions opts = new FirefoxOptions();
if (HEADLESS_MODE) {
opts.addArguments(ARG_HEADLESS);
}
return new FirefoxDriver(opts);
It's working fine on my machine (and on machines of other developers) in both modes "headless" and normal. Now I'm trying to run Selenium tests with CI builds in Alpine Linux Docker container. When I tried to run it as-is, I've got an error:
mozrunner::runner INFO Running command: "/usr/bin/firefox"
"-marionette" "--headless" "-foreground" "-no-remote"
"-profile" "/tmp/rust_mozprofile.pW1sbkcv98QN"
Error: GDK_BACKEND does not match available displays.
Then I installed all suggested tools (dbus and xvfb) from this post and started it before running tests:
apk add xvfb dbus
dbus-uuidgen > /etc/machine-id
export DISPLAY=:99
Xvfb $DISPLAY -ac &
mvn verify
but now Selenium tests are hadning for about 10 seconds and failing with error
1565433736375 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "--headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.1ZMsJ0Hy95V0"
1565433738424 Marionette INFO Listening on port 2828
!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv
[Child 2191] ###!!! ABORT: Aborting on channel error.: file /home/buildozer/aports/community/firefox-esr/src/firefox-52.8.1esr/ipc/glue/MessageChannel.cpp, line 2152
[Child 2191] ###!!! ABORT: Aborting on channel error.: file /home/buildozer/aports/community/firefox-esr/src/firefox-52.8.1esr/ipc/glue/MessageChannel.cpp, line 2152
!!! [Child][MessageChannel] Error: (msgtype=0x3E0003,name=PCompositable::Msg_Destroy) Channel error: cannot send/recv
It seems I'm doing something wrong here, what is the correct way to run headless Selenium tests in Alpine Linux Docker container? I'd prefer to configure existing Docker image instead of using Selenium images, because the migration will be expensive.
Update:
Selenium version is 3.141.59
Gecko-driver version is v0.24.0-linux64
Firefox-ESR version is: 52.8.1-r0
Update2:
xvfb, dbus and exported DISPLAY are not actually needed to run Firefox in headless mode - just run firefox --headless and it's all.
As per Mozilla --headless flag is not supported in Firefox 52-esr.Headless flag was introduced in version 55 (for Linux) and 56 (Mac/Windows) . Please try on latest Firefox ESR release.
Issue :
We are running NightWatch tests in Jenkins, and once in a while, we get this error :
[0;31mConnection refused! Is selenium server started?
[0m[0;90m{ Error: socket hang up
at createHangUpError (_http_client.js:253:15)
at Socket.socketCloseListener (_http_client.js:285:23)
at emitOne (events.js:101:20)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:501:12) code: 'ECONNRESET' }[0m
The fix recommended in other places is already there :
export DBUS_SESSION_BUS_ADDRESS=/dev/null
This is how we run the tests :
sudo npm install selenium-standalone -g
selenium-standalone install --version=3.0.1 --baseURL=https://selenium-release.storage.googleapis.com --drivers.chrome.version=2.28 --drivers.chrome.baseURL=https://chromedriver.storage.googleapis.com --basePath=bin
sudo npm install nightwatch#0.9.13 -g && nightwatch --tag sanity --retries 1 --suiteRetries 1
Rebuilding the job usually run the tests successfully.
Softwares' version:
Chrome : 57
Chrome driver : 2.28
Selenium: 3.0.1
NightWatch : 0.9.13 (bumped down from 0.9.14 in case the latest release had a bug but no change.)
Jenkins : 1.6x
Ubuntu : 16.04
Using xvfb
Error Scenarios
The tests were running fine until about 2 weeks ago, just when we switched to Ubuntu 16, but that day it started happening on Ubuntu 14 too.
It especially happens when we've just spun a new Jenkins slave (on AWS cloud.) Happens more often at the very start of the test run but sometimes it happens in the middle of the run too.
I'll appreciate any help or pointers!
I have the same problem yesterday.
Maybe you can change the version of Chrome.
such as Chrome:55.
when i changed the version of chrome the selenium
We ran into a similar issue, but our error message was more specific:
Selenium is already running on port ####. Or some other service is.
The solution was to use the Jenkins Port Allocator Plugin to assign an available port number to an environment variable.
From there, we were able to set the port number in our globals.js like this (with a default of 4444 for running locally):
portNumber: process.env.PORT_NUMBER || 4444,
In our nightwatch.conf.js file, we used a lodash template to replace values in our nightwatch.json like this:
fs = require('fs'),
_ = require('lodash'),
template = _.template(fs.readFileSync('./nightwatch.json', 'utf8')),
settingsString,
settings;
settingsString = template({
portNumber: globals.portNumber
});
settings = JSON.parse(settingsString);
module.exports = settings;
Finally, in our nightwatch.conf file, we set the values for all port references to:
"<%= portNumber %>"