Run Selenium server with a webdriver - selenium

~/tests > uname -a
Linux ghopper-K52F 4.10.0-40-generic #44-Ubuntu SMP Thu Nov 9 14:49:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
~/tests > ls -al
total 37404
drwxrwxr-x 2 ghopper ghopper 4096 ноя 23 22:05 .
drwxr-xr-x 33 ghopper ghopper 4096 ноя 24 10:53 ..
-rwxr-xr-x 1 ghopper ghopper 8799120 ноя 23 10:51 chromedriver
-rwxrwxr-x 1 ghopper ghopper 7194178 окт 31 22:15 geckodriver
-rw-rw-r-- 1 ghopper ghopper 22234765 ноя 23 10:52 selenium-server-standalone-3.7.1.jar
~/tests > apt list --installed | grep openjdk
openjdk-9-jre-headless/zesty,now 9~b161-1 amd64 [installed]
I want to start the server with chromedriver
~/tests > java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.7.1.jar
2017-11-24 11:12:16.560:INFO::main: Logging initialized #3822ms to org.seleniumhq.jetty9.util.log.StdErrLog
2017-11-24 11:12:18.501:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-11-24 11:12:18.577:WARN:osjs.SecurityHandler:main: ServletContext#o.s.j.s.ServletContextHandler#58a9760d{/,null,STARTING} has uncovered http methods for path: /
2017-11-24 11:12:18.587:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#58a9760d{/,null,AVAILABLE}
2017-11-24 11:12:18.662:INFO:osjs.AbstractConnector:main: Started ServerConnector#66a17408{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-11-24 11:12:18.663:INFO:osjs.Server:main: Started #5924ms
As we can see, there is not any mention about the webdriver.
All my tests were failed and the browser didn't run at all. I got the log snippet in the server's console:
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 8315
Only local connections are allowed.
And the test's issue:
./vendor/bin/phpunit -v -c tests/phpunit.xml tests/src/Selenium/LoginTest.php
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
Runtime: PHP 7.0.22-0ubuntu0.17.04.1
Configuration: /home/ghopper/work/***/tests/phpunit.xml
ESSSS
Time: 12.19 seconds, Memory: 6.00MB
There was 1 error:
1) Package\Test\Selenium\LoginTest::testUnauthorizedRandomPage
PHPUnit_Extensions_Selenium2TestCase_WebDriverException:
/home/ghopper/work/***/vendor/phpunit/phpunit selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:165
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/Driver.php:71
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/SessionStrategy/Isolated.php:67
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase/SessionStrategy/Shared.php:79
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:246
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:287
/home/ghopper/work/***/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:264
--
There were 4 skipped tests:
...
The questions:
Why Selenium runs without the webdriver.
How to debug the server? Where is the error and its cause?
How to check java and its environment?
P.S. I do the same things on an another PC and all works fine for me. I think the problem is in environment, not in the server's config.

~/tests > sudo apt-get purge openjdk-9-jre-headless
~/tests > sudo apt install openjdk-8-jre-headless
~/tests > java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.7.1.jar
12:48:44.839 INFO - Selenium build info: version: '3.7.1', revision: '8a0099a'
12:48:44.841 INFO - Launching a standalone Selenium Server
2017-11-24 12:48:44.885:INFO::main: Logging initialized #534ms to org.seleniumhq.jetty9.util.log.StdErrLog
12:48:45.006 INFO - Driver class not found: com.opera.core.systems.OperaDriver
12:48:45.099 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities {browserName: internet explorer, ensureCleanSession: true, platform: WINDOWS, version: }
does not match the current platform LINUX
12:48:45.099 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: }
does not match the current platform LINUX
12:48:45.100 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform LINUX
12:48:45.226 INFO - Using the passthrough mode handler
2017-11-24 12:48:45.280:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-11-24 12:48:45.347:WARN:osjs.SecurityHandler:main: ServletContext#o.s.j.s.ServletContextHandler#30a3107a{/,null,STARTING} has uncovered http methods for path: /
2017-11-24 12:48:45.365:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#30a3107a{/,null,AVAILABLE}
2017-11-24 12:48:45.414:INFO:osjs.AbstractConnector:main: Started ServerConnector#56c57463{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-11-24 12:48:45.414:INFO:osjs.Server:main: Started #1063ms
12:48:45.414 INFO - Selenium Server is up and running
Now everything works fine! Thank you )

Related

Tests fail immediately with unknown error: DevToolsActivePort file doesn't exist when running Selenium grid through systemd

I've been trying to change the way I start the Selenium grid service from a shell script in .rclocal to a systemd service, but it is not working. The script is this:
#!/bin/bash
java -jar /opt/selenium-server-standalone.jar -role hub -hubConfig hubconfig.json
xvfb-run --server-args="-screen 0 2048x1536x24" java -jar /opt/selenium-server-standalone.jar -role
node -nodeConfig nodeconfig.json
I created two different services as follows:
(Stackoverflow won't let me put the contents of the services as it says it is not properly formated)
The services are starting correctly:
selenium-hub
● selenium-hub.service - Selenium service
Loaded: loaded (/etc/systemd/system/selenium-hub.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-10-01 15:53:10 UTC; 2min 41s ago
Main PID: 23803 (java)
CGroup: /system.slice/selenium-hub.service
└─23803 /bin/java -jar /opt/selenium-server-standalone.jar -role hub -hubConfig /home/selenium/hubconfig.json
Oct 01 15:53:12 vm java[23803]: 15:53:12.163 INFO - Selenium build info: version: '3.9.1', revision: '63f7b50'
Oct 01 15:53:12 vm java[23803]: 15:53:12.164 INFO - Launching Selenium Grid hub on port 4444
Oct 01 15:53:13 vm java[23803]: 2019-10-01 15:53:13.384:INFO::main: Logging initialized #2790ms to org.seleniumhq.jetty9.util.log.StdErrLog
Oct 01 15:53:13 vm java[23803]: 2019-10-01 15:53:13.492:INFO:osjs.Server:main: jetty-9.4.7.v20170914, build timestamp: 2017-11-21T21:27:37Z, git hash: 82b8fb23f757335bb3329d540ce37a2a2615f0a8
Oct 01 15:53:13 vm java[23803]: 2019-10-01 15:53:13.524:INFO:osjs.session:main: DefaultSessionIdManager workerName=node0
Oct 01 15:53:13 vm java[23803]: 2019-10-01 15:53:13.524:INFO:osjs.session:main: No SessionScavenger set, using defaults
Oct 01 15:53:13 vm java[23803]: 2019-10-01 15:53:13.529:INFO:osjs.session:main: Scavenging every 660000ms
Oct 01 15:53:13 vm java[23803]: 2019-10-01 15:53:13.538:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#60704c{/,null,AVAILABLE}
Oct 01 15:53:13 vm java[23803]: 2019-10-01 15:53:13.562:INFO:osjs.AbstractConnector:main: Started ServerConnector#1fe20588{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
Oct 01 15:53:13 vm java[23803]: 2019-10-01 15:53:13.562:INFO:osjs.Server:main: Started #2968ms
Oct 01 15:53:13 vm java[23803]: 15:53:13.562 INFO - Selenium Grid hub is up and running
Oct 01 15:53:13 vm java[23803]: 15:53:13.562 INFO - Nodes should register to http://1.2.3.4:4444/grid/register/
Oct 01 15:53:13 vm java[23803]: 15:53:13.562 INFO - Clients should connect to http://1.2.3.4:4444/wd/hub
Oct 01 15:53:14 vm java[23803]: 15:53:14.797 INFO - Registered a node http://1.2.3.4:5555
selenium-node:
● selenium-node.service - Selenium nodes
Loaded: loaded (/etc/systemd/system/selenium-node.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-10-01 15:53:10 UTC; 6min ago
Main PID: 23813 (xvfb-run)
CGroup: /system.slice/selenium-node.service
├─23813 /bin/sh /bin/xvfb-run --server-args="-screen 0 2048x1536x24" java -jar /opt/selenium-server-standalone.jar -role node -nodeConfig /home/selenium/nodeconfig.json
├─23856 java -jar /opt/selenium-server-standalone.jar -role node -nodeConfig /home/selenium/nodeconfig.json
├─24326 /usr/local/bin/chromedriver --port=1713
├─24327 /usr/local/bin/chromedriver --port=26741
├─24328 /usr/local/bin/chromedriver --port=20065
├─24329 /usr/local/bin/chromedriver --port=6459
├─24331 /usr/local/bin/chromedriver --port=15872
├─24332 /usr/local/bin/chromedriver --port=29475
├─24333 /usr/local/bin/chromedriver --port=30216
├─24334 /usr/local/bin/chromedriver --port=6955
├─24558 /usr/local/bin/chromedriver --port=2425
├─24559 /usr/local/bin/chromedriver --port=19304
├─24560 /usr/local/bin/chromedriver --port=12150
├─24561 /usr/local/bin/chromedriver --port=26147
├─24562 /usr/local/bin/chromedriver --port=16545
├─24570 /usr/local/bin/chromedriver --port=12780
├─24602 /usr/local/bin/chromedriver --port=10959
├─24603 /usr/local/bin/chromedriver --port=8970
├─24753 /usr/local/bin/chromedriver --port=13438
├─24754 /usr/local/bin/chromedriver --port=15725
└─24772 /usr/local/bin/chromedriver --port=28829
Oct 01 15:55:19 vm xvfb-run[23813]: Starting ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865#{#442}) on port 15725
Oct 01 15:55:19 vm xvfb-run[23813]: Only local connections are allowed.
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.112 INFO - /session: Executing POST on /session (handler: BeginSession)
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.113 INFO - Capabilities are: Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.114 INFO - Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm-usage, window-siz
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.115 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#53702c02
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.115 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#4ae12041
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.116 INFO - /session: Executing POST on /session (handler: BeginSession)
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.117 INFO - Capabilities are: Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.118 INFO - Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm-usage, window-siz
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.118 INFO - /session: Executing POST on /session (handler: BeginSession)
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.120 INFO - Capabilities are: Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.120 INFO - Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm-usage, window-siz
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.121 INFO - /session: Executing POST on /session (handler: BeginSession)
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.123 INFO - Capabilities are: Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.123 INFO - Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm-usage, window-siz
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.124 INFO - /session: Executing POST on /session (handler: BeginSession)
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.139 INFO - Capabilities are: Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm
Oct 01 15:55:19 vm xvfb-run[23813]: 15:55:19.139 INFO - Capabilities {browserName: chrome, goog:chromeOptions: {args: [enable-automation, disable-infobars, disable-notifications, no-sandbox, --disable-dev-shm-usage, window-siz
Oct 01 15:55:19 vm xvfb-run[23813]: Starting ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865#{#442}) on port 26147
Oct 01 15:55:19 vm xvfb-run[23813]: Only local connections are allowed.
Oct 01 15:55:19 vm xvfb-run[23813]: Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
However all tests fails with the same error:
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
The problem with DevToolsActivePort is derived from /dev/shm being too small and sometimes crashing the browser (https://stackoverflow.com/a/50642913/5364231, https://bugs.chromium.org/p/chromium/issues/detail?id=736452#c64) so I already added --disable-dev-shm-usage to the capabilities.
The problem, I think, resided in the service selenium-hub not being able to communicate with selenium-node. Any help is greatly appreciated.
Thumb rule
A common cause for Chrome to crash during startup is running Chrome 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 Chrome as a regular user instead.
This error message...
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:42:28.403Z'
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using the latest chromedriver=77.0
Presumably you are using chrome= 77.0.
Your Selenium Client version is 3.9.1 of 2018-02-07T22:42:28.403Z which is almost 1.5 years older.
So there is a clear mismatch between the Selenium Client v3.9.1 , ChromeDriver v77.0 and the Chrome Browser v77.0
Solution
Ensure that:
JDK is upgraded to current levels JDK 8u221.
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v77.0 level.
Chrome is updated to current Chrome Version 77.0 level. (as per ChromeDriver v77.0 release notes)
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 and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Reference
You can find a couple of detailed discussions in:
org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
unknown error: DevToolsActivePort file doesn't exist error while executing Selenium UI test cases on ubuntu
Outro
Here is the link to the Sandbox story.
Sometimes this Happens when Chrome is Updated to newer version but driver binaries are still older. Make sure that Chrome browser and ChromeDriver have the same version

How to fix this Selenium Error: bind() failed: Cannot assign requested address (99)

I've installed the latest version of selenium via Docker:
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:latest
and then ran this in my python console:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.CHROME)
and finally checked the docker logs:
2019-04-24 19:09:26,880 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2019-04-24 19:09:26,881 INFO supervisord started with pid 8
2019-04-24 19:09:27,865 INFO spawned: 'xvfb' with pid 11
2019-04-24 19:09:27,867 INFO spawned: 'selenium-standalone' with pid 12
19:09:28.038 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
2019-04-24 19:09:28,039 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2019-04-24 19:09:28,039 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
19:09:28.093 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-04-24 19:09:28.126:INFO::main: Logging initialized #247ms to org.seleniumhq.jetty9.util.log.StdErrLog
19:09:28.289 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
19:09:28.349 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
19:09:43.631 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"version": ""
}
19:09:43.633 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729#{#29}) on port 22103
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1556132983.659][SEVERE]: bind() failed: Cannot assign requested address (99)
19:09:44.266 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
19:09:44.490 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session cedc7067c0133f6492ff65dda5c7dd88 (org.openqa.selenium.chrome.ChromeDriverService)
In particular, I'm unsure of how to fix this error:
[1556132983.659][SEVERE]: bind() failed: Cannot assign requested address (99)
I'm running this on my macbook pro using Mojave with the latest version of docker, python, and selenium. I also tried using other ports aside from 4444, same result. Thanks!
We have seen that entry in the logs for a long time, however, there is no evidence it affects your tests. The message comes directly from ChromeDriver/Chrome. It is safe to ignore it.

selenium server standalone: unable to create a new session with vagrant in headless mode

I am trying to run the selenium server standalone in a vagrant box, with the following command:
java -jar selenium-server-standalone-3.13.0.jar
When I click the 'create session' button at http://lab.local:4444/wd/hub/static/resource/hub.html from my host web browser. I get a unable to create a new session error message.
I ask to create a firefox browser session for which I get the driver located in /usr/local/bin/geckodriver.
Firefox has been installed on the vagrant box with sudo apt install firefox-esr.
Error log detail:
14:52:04.485 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.13.0', revision: '2f0d292'
14:52:04.486 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-08-09 14:52:04.564:INFO::main: Logging initialized #312ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:52:04.757 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
14:52:15.563 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "firefox"
}
14:52:15.568 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
1533819135611 geckodriver INFO geckodriver 0.21.0
1533819135614 geckodriver INFO Listening on 127.0.0.1:25541
1533819135880 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.yuusnpGo8Gw6"
1533819136508 Marionette INFO Listening on port 2828
When I run the same executable directly from my host, I get no error and the firefox session is created with success.
I try to run a X server, Xvfb as follow but this does not change anything:
Xvfb :1 -screen 0 1600x1200x16 &
export DISPLAY=:1
java -jar selenium-server-standalone-3.13.0.jar
Problem solved after switching to selenium-server-standalone-3.3.1.jar with geckodriver 0.14.0. Sessions are created with success with this configuration.
source.

Headless Chrome Circle CI - Error: spawn /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/bin/java ENOENT

I am trying to run tests in Circle CI in headless chrome.
I am using selenium server version 3.8.1 and chromedriver version 2.34
protractor_conf.js consists of chrome capabilities as:
var chromeCapabilities = {
browserName: 'chrome',
chromeOptions: {  
args: [
'headless','--show-fps-counter=false', '--remote-debugging-port=2222', '--disable-gpu'
]
}
}
My sh script includes following commands for webdriver-manager and then running tests:
./node_modules/protractor/bin/webdriver-manager clean
./node_modules/protractor/bin/webdriver-manager update --gecko false --versions.standalone 3.8.1 --versions.chrome 2.34
./node_modules/protractor/bin/webdriver-manager start &
echo "*** Run script for e2e tests"
gulp e2e
I added these in m circle.yml to install latest version of stable chrome and launched headless listening to localhost:
dependencies:
post:
# Install the latest Chrome
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome.deb
- sudo sed -i 's|HERE/chrome\"|HERE/chrome\" --disable-setuid-sandbox|g' /opt/google/chrome/google-chrome
- rm google-chrome.deb
before_install:
- google-chrome --headless --remote-debugging-port=2222 --disable-gpu http://localhost &
So, when I run my build now, the tests don't run at all. Logs say:
** Updating webdriver **
[05:46:11] W/file_manager - path does not exist
/home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-
manager/selenium
[05:46:11] I/file_manager - creating folder
/home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-
manager/selenium
[05:46:12] I/update - chromedriver: unzipping chromedriver_2.34.zip
[05:46:12] I/update - chromedriver: setting permissions to 0755 for
/home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-
manager/selenium/chromedriver_2.34
[05:46:13] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.34 -jar /home/ubuntu/pharma/test/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.8.1.jar -port 4444
[05:46:13] I/start - seleniumProcess.pid: 24198
05:46:13.642 INFO - Selenium build info: version: '3.8.1', revision: '6e95a6684b'
05:46:13.643 INFO - Launching a standalone Selenium Server
2018-01-12 05:46:13.740:INFO::main: Logging initialized #385ms to org.seleniumhq.jetty9.util.log.StdErrLog
05:46:13.781 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
05:46:13.799 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
05:46:13.801 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
05:46:13.803 INFO - Driver class not found: com.opera.core.systems.OperaDriver
05:46:13.803 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
05:46:13.803 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
05:46:13.804 INFO - Driver class not found: org.openqa.selenium.phantomjs.PhantomJSDriver
05:46:13.845 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities {browserName: internet explorer, ensureCleanSession: true, platform: WINDOWS, version: } does not match the current platform LINUX
05:46:13.845 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities {browserName: MicrosoftEdge, platform: WINDOWS, version: } does not match the current platform LINUX
05:46:13.846 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform LINUX
05:46:13.891 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
05:46:13.892 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
05:46:13.892 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
05:46:13.893 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
05:46:13.893 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
05:46:13.902 INFO - Using the passthrough mode handler
2018-01-12 05:46:13.932:INFO:osjs.Server:main: jetty-9.4.7.v20170914
2018-01-12 05:46:13.970:WARN:osjs.SecurityHandler:main: ServletContext#o.s.j.s.ServletContextHandler#2db7a79b{/,null,STARTING} has uncovered http methods for path: /
2018-01-12 05:46:13.978:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#2db7a79b{/,null,AVAILABLE}
2018-01-12 05:46:13.998:INFO:osjs.AbstractConnector:main: Started ServerConnector#67b467e9{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2018-01-12 05:46:13.999:INFO:osjs.Server:main: Started #644ms
05:46:13.999 INFO - Selenium Server is up and running
[07:02:53] Using gulpfile ~/pharma/test/gulpfile.babel.js
[07:02:53] Starting 'set-envVars'...
[07:02:53] Finished 'set-envVars' after 245 μs
[07:02:53] Starting 'set-directories'...
[07:02:53] Finished 'set-directories' after 428 μs
[07:02:53] Starting 'e2e'...
--> Running tests using command: ./node_modules/.bin/protractor ./protractor_e2e_conf.js
Logger: Output file - /home/ubuntu/pharma/test/output/e2e/logs/console.log
[07:02:54] [INFO] Report destination: /home/ubuntu/pharma/test/output/e2e/logs/e2eTests.html
[07:02:54] [INFO] [07:02:54] I/launcher - Running 1 instances of WebDriver
[07:02:55] [INFO] [07:02:55] I/testLogger -
------------------------------------
[07:02:55] [INFO] [07:02:55] I/testLogger - [Chrome] PID: 24232
[Chrome] Specs: /home/ubuntu/pharma/test/e2e/spec/targeting/data_upload/uploadAccount_spec.js
[Chrome]
[Chrome] Logger: Output file - /home/ubuntu/pharma/test/output/e2e/logs/console.log
[Chrome] [07:02:55] [INFO] [07:02:55] I/local - Starting selenium standalone server...
[Chrome] events.js:160
[Chrome] throw er; // Unhandled 'error' event
[Chrome] ^
[Chrome]
[Chrome] Error: spawn /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/bin/java ENOENT
[Chrome] at exports._errnoException (util.js:1018:11)
[Chrome] at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
[Chrome] at onErrorNT (internal/child_process.js:367:16)
[Chrome] at _combinedTickCallback (internal/process/next_tick.js:80:11)
[Chrome] at process._tickCallback (internal/process/next_tick.js:104:9)
Versions used:
Chrome browser version: Google Chrome 63.0.3239.132
Protractor:v5.2.2
Chromedriver zip: 2.34
Selenium standalone: 3.8.1
Circle CI: 1.0
What am I missing?
Any help would be appreciated.
Solution:
The default java version installed on circle ci is 1.7. I forced it to install 1.8 jdk:
Went to circle ci build test commands and used: java --version command to check java version installed. Got v1.7 form there.
Then, I modified my Dockerfile to use jdk 8 by using: FROM openjdk:8
This would overwrite the v1.7 installed and force use 1.8 which solved my problem.

Selenium Hub + Node: Cleaning up stale test sessions on the unregistered node

I have two machines:
1. Linux Centos 6.4
2. Mac OS X 10.8
Linux starts the hub:
[root#jenkins tools]# java -jar selenium-server-standalone-2.46.0.jar -role hub -port 4444
11:35:00.898 INFO - Launching Selenium Grid hub
2015-06-15 11:35:01.744:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2015-06-15 11:35:01.969:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
2015-06-15 11:35:02.028:INFO:osjs.AbstractConnector:Started SocketConnector#0.0.0.0:4444
11:35:02.029 INFO - Nodes should register to http://192.168.1.110:4444/grid/register/
11:35:02.031 INFO - Selenium Grid hub is up and running
Then I start the node (Mac):
tomas#tororrosso ~/Q/A/tools> java -jar selenium-server-standalone-2.46.0.jar -role node -hub http://192.168.1.110:4444/grid/register/ -host "http://192.168.1.254" -port 4445 --debug
11:36:00.190 INFO - Launching a Selenium Grid node
11:36:00.635 INFO - Java: Apple Inc. 20.51-b01-457
11:36:00.635 INFO - OS: Mac OS X 10.8.5 x86_64
11:36:00.639 INFO - v2.46.0, with Core v2.46.0. Built from revision 87c69e2
11:36:00.675 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform MAC
11:36:00.676 INFO - Driver class not found: com.opera.core.systems.OperaDriver
11:36:00.676 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
11:36:00.678 INFO - Driver class is built for higher Java version: org.openqa.selenium.htmlunit.HtmlUnitDriver
11:36:00.678 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
11:36:00.693 INFO - Version Jetty/5.1.x
11:36:00.694 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
11:36:00.694 INFO - Started HttpContext[/selenium-server,/selenium-server]
11:36:00.694 INFO - Started HttpContext[/,/]
11:36:00.700 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#65493102
11:36:00.700 INFO - Started HttpContext[/wd,/wd]
11:36:00.702 INFO - Started SocketListener on 0.0.0.0:4445
11:36:00.702 INFO - Started org.openqa.jetty.jetty.Server#2092dcdb
11:36:00.703 INFO - Selenium Grid node is up and ready to register to the hub
11:36:00.726 INFO - Starting auto registration thread. Will try to register every 5000 ms.
11:36:00.727 INFO - Registering the node to the hub: http://192.168.1.110:4444/grid/register
11:36:00.735 INFO - The node is registered to the hub and ready to use
Everything seems so perfect and wonderful until....
In the hub:
11:36:50.904 WARN - Cleaning up stale test sessions on the unregistered node http://http://192.168.1.254:4445
And the node:
11:36:05.774 INFO - Registering the node to the hub: http://192.168.1.110:4444/grid/register
11:36:05.785 INFO - The node is registered to the hub and ready to use
And they are like this to the infinity and beyond.
More Information
Both machines can see each other:
tomas#tororrosso ~> ping 192.168.1.110
PING 192.168.1.110 (192.168.1.110): 56 data bytes
64 bytes from 192.168.1.110: icmp_seq=0 ttl=64 time=0.585 ms
64 bytes from 192.168.1.110: icmp_seq=1 ttl=64 time=0.586 ms
64 bytes from 192.168.1.110: icmp_seq=2 ttl=64 time=0.606 ms
^C
--- 192.168.1.110 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.585/0.592/0.606/0.010 ms
[root#jenkins ]# ping 192.168.1.254
PING 192.168.1.254 (192.168.1.254) 56(84) bytes of data.
64 bytes from 192.168.1.254: icmp_seq=1 ttl=64 time=0.521 ms
64 bytes from 192.168.1.254: icmp_seq=2 ttl=64 time=0.541 ms
^C
--- 192.168.1.254 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1933ms
rtt min/avg/max/mdev = 0.521/0.531/0.541/0.010 ms
I tried this too:
java -jar selenium-server-standalone-2.46.0.jar -role node -hubHost 192.168.1.110 -hubPort 4444 -host "http://192.168.1.254" -port 4446 --debug
But every 5 seconds it keeps re-registering.
I just executed the node with this config and it worked:
{
"capabilities":
[
{
"browserName": "firefox",
"version": "38.0.5",
"platform": "MAC",
"maxInstances": 1
},
{
"browserName": "chrome",
"version": "43",
"platform": "MAC",
"maxInstances": 1
}
],
"configuration":
{
"nodeTimeout":120,
"host":"192.168.1.254",
"port":4446,
"hubPort":4444,
"hubHost":"192.168.1.110",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
Saved it as mac.json
Then executed the node as:
tomas#tororrosso ~> java -jar selenium-server-standalone-2.46.0.jar -role node -nodeConfig mac.json
And everything worked correctly.