getting error when executing the selenium testng tests in jenkins job in centos7.6 VM - selenium

I am able to execute the tests in windows properly, but when I create the jenkins job in centos7.6 VM and the jenkins job console output shows the below error.
This is what I have defined in the code:
{
System.setProperty("webdriver.chrome.driver", "/tmp/chromedriver_linux");
}
driver = new ChromeDriver();
Below is the error:
enter code here Test01(com.training.multi.browser.testing.MultiTests) Time elapsed: 2.164 sec <<< FAILURE!
org.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/chromium-browser is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=75.0.3770.140 (2d9f97485c7b07dc18a74666574f19176731995c-refs/branch-heads/3770#{#1155}),platform=Linux 3.10.0-957.27.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.66 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.27.2.el7.x86_64', java.version: '1.8.0_222'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at com.training.multi.base.BaseTest.getDriver(BaseTest.java:19)
at com.training.multi.browser.testing.MultiTests.Test01(MultiTests.java:36)`

There are a couple of additional steps you need to take in order to make test running in Jenkins on Linux via setting extra ChromeOptions
Make sure to add --headless argument as systems running Jenkins normally don't have GUI
If you're running Jenkins as root user you also need to set --no-sandbox option
Something like:
ChromeOptions options = new ChromeOptions();
options.addArguments(Arrays.asList("--headless", "--no-sandbox"));
options.setBinary("/path/to/chromedriver");
ChromeDriver driver = new ChromeDriver(options);
Also make sure that the user has appropriate permissions in order to launch the chromedriver binary, if not - grant them using chmod command like:
chmod +x /tmp/chromedriver_linux
More information: How to use Jenkins pipeline to launch Selenium tests

(unknown error: DevToolsActivePort file doesn't exist)
This error is caused when there is incompatibility in version of chrome and chromedriver you are using. Upgrade chrome browser on your centos machine and download the new chrome version compatible chromedriver.

Related

WebDriverException: unknown error: Chrome failed to start: exited abnormally error running Selenium Grid on Server using ChromeDriver and Chrome

Good evening,
I tried to run my automated tests on a server with Eclipse / Selenium and TestNG. So far the configuration of Selenium Grid worked fine. I got the response:
23:02:55.068 INFO - Selenium Grid hub is up and running
23:03:30.488 INFO - Registered a node http://81.169.xxx.xxx:5555 <br>
23:05:25.423 INFO - Registering the node to the hub: http://81.169.xxx.xxx:4444/grid/register
23:05:25.432 INFO - The node is registered to the hub and ready to use
Here's my example code:
#Test
public void executeOnServer() throws MalformedURLException {
System.out.println("Test started");
DesiredCapabilities dcp = new DesiredCapabilities();
dcp.setBrowserName("chrome");
dcp.setPlatform(Platform.ANY);
WebDriver driver = new RemoteWebDriver(new URL("http://81.169.xxx.xxx:5555/wd/hub/"), dcp);
driver.manage().window().maximize();
driver.get("https://google.de");
driver.quit();
}
Unfortunately I got the error:
[RemoteTestNG] detected TestNG version 6.14.3
Test started
FAILED: executeOnServer
org.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.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'h28xxxxx.stratoserver.net', ip: '81.169.xxx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0', java.version: '1.8.0_252'
Driver info: driver.version: ChromeDriver
remote stacktrace: #0 0x559967ec9ea9 <unknown>
The path to the chromedriver is:
usr/local/bin/chromedriver
Installed version:
https://chromedriver.storage.googleapis.com/index.html?path=**84.0.4147.30**/chromedriver_linux64.zip
Do you have any idea how I could fix the error? Had a look at different sites with this error, no solution is working for me.
This error message...
Test started
FAILED: executeOnServer
org.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.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'h28xxxxx.stratoserver.net', ip: '81.169.xxx.xxx', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0', java.version: '1.8.0_252'
Driver info: driver.version: ChromeDriver
remote stacktrace: #0 0x559967ec9ea9 <unknown>
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context 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 chromedriver=84.0
Possibly you are using the latest chrome=84.0
Your Selenium Client version is 3.4.0 of revision: 'unknown', time: 'unknown'
So that implies the ChromeDriver is unable to interact with the Selenium bindings as there is a clear mismatch between Selenium v3.4.0 and the ChromeDriver v84.0
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v84.0 level.
Chrome is updated to current Chrome Version 84.0 level. (as per ChromeDriver v84.0 release notes)
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

running selenium webdriver with firefox profile results in WebDriverError: connection refused

I am trying to start a selenium test with the following command
selenium-side-runner --server http://127.0.0.1:4444/wd/hub --debug -c
"browserName='firefox' moz:firefoxOptions.args=[-profile, /home/seluser.
/firefox-profile/myprofile]" --output-directory ~/out ~/portallogin.side
The profile is loaded correctly in firefox then but the test fails to run with the following exception:
Test suite failed to run
WebDriverError: connection refused
Build info: version: '3.141.59', revision: '82b03c358b', time: '2019-04-30T22:04:50'
System info: host: 'd871aae50a23', ip: '172.17.0.3', os.name: 'Linux', os.arch:
'amd64', os.version: '4.4.0-1075-aws', java.version: '1.8.0_212'
Driver info: driver.version: unknown
remote stacktrace:
at Object.checkLegacyResponse (../../../usr/lib/node_modules/
selenium-side-runner/node_modules/selenium-webdriver/lib/error.js:585:15)
at parseHttpResponse (../../../usr/lib/node_modules/
selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:551:13)
at Executor.execute (../../../usr/lib/node_modules/
selenium-side-runner/node_modules/selenium-webdriver/lib/http.js:486:26)
While running the same test without the profile beeing loaded is working.
I have found this issue: https://github.com/SeleniumHQ/selenium-ide/issues/616 and it looks like a bug.
I tried to add a .side.yml file but that didn't help yet.
It looks like the loading of a profile is disabling the webdriver functionallity in firefox. Any hints how to get it running?
There is a workaround provided here https://github.com/mozilla/geckodriver/issues/1058#issuecomment-350254437
We need to pass the --marionette-port 2828 during the selenium execution.

org.openqa.selenium.SessionNotCreatedException because of "Chrome version must be >= 64.0.3282.0" although version is 65.0.3325.181 on Travis CI

While I was attempting to extend Arquillian PrimeFaces's .travis.yml with a setup for phantomjs and chromeheadless browser driver for functional tests with Selenium, I experienced
java.lang.RuntimeException: Could not create statement
Caused by: java.lang.RuntimeException:
Unable to instantiate Drone via org.openqa.selenium.chrome.ChromeDriver(Capabilities): org.openqa.selenium.SessionNotCreatedException: session not created exception: Chrome version must be >= 64.0.3282.0
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux 4.4.0-101-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 564 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'travis-job-bdbf5b81-b2fa-4377-b5de-da7743f04986', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-101-generic', java.version: '1.8.0_151'
Driver info: driver.version: ChromeDriver
Caused by: org.openqa.selenium.SessionNotCreatedException:
session not created exception: Chrome version must be >= 64.0.3282.0
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux 4.4.0-101-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 564 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'travis-job-bdbf5b81-b2fa-4377-b5de-da7743f04986', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-101-generic', java.version: '1.8.0_151'
Driver info: driver.version: ChromeDriver
So, I updated chromium-browser with sudo add-apt-repository --yes ppa:saiarcot895/chromium-dev && sudo apt-get update && sudo apt-get install --yes chromium-browser and verified that it's the only Chrome binary and has a matching version with which -a chromium-browser && chromium-browser --version which reveals that the only binary is /usr/bin/chrominum-browser and has version 65.0.3325.181. However, the error persists.
I researched and found issues with Chrome on Travis CI like
https://github.com/travis-ci/travis-ci/issues/938 which is about permissions (as opposed to versions)
Chromedriver on Travis-CI which summarizes issues
and checked the Arquillian web driver configuration options for Chrome which don't seem to include one to expose the actual pick up of the ghost 64.x binary.
An example run of the failure can be found at https://travis-ci.org/krichter722/arquillian-primefaces/jobs/364342730.
In your question you have mentioned about using Chrome v65.0.3325.181 but the error stack strace shows different versions as follows :
Caused by: org.openqa.selenium.SessionNotCreatedException:
session not created exception: Chrome version must be >= 64.0.3282.0
This essentially means ChromeDriver is unable to detect the right version of chrome binary. It appears you either have installed multiple instances of Chrome Browsers and have multiple instances of chrome binaries within your system or there are multiple stray instances of chrome binaries available within your system.
Solution
You must ensure that Chrome is installed at the optimum location as the server expects you to have Chrome installed in the default location for each system as per the snapshot below :
Note : For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. You can also override the Chrome binary location following the documentation Using a Chrome executable in a non-standard location.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
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.
Take a System Reboot.
Execute your #Test.

error in selenium node when run as a cron job

I am facing an unusual error while my selenium script tries to run automation tests by connecting to node which has been started using crontab (as shown below)
#reboot sh /home/selenium/automation/nodeStartUp.sh &
The nodeStartUp.sh content is shown below:
#!/bin/bash
java -jar /home/selenium/automation/selenium-server-standalone-3.0.0-beta3.jar -role node -nodeConfig /home/selenium/automation/node.json -log /home/selenium/automation/node.log
The error shown is as below: (Note: This error does not appear when I start the script manually and execute the testcases)
09:25:08.919 INFO [20] org.openqa.grid.internal.utils.SelfRegisteringRemote - Registering the node to the hub: http://XXX.XXX.XXX.XXX:4444/grid/register
09:25:08.940 INFO [20] org.openqa.grid.internal.utils.SelfRegisteringRemote - The node is registered to the hub and ready to use
09:25:10.972 INFO [17] org.openqa.selenium.remote.server.DriverServlet - Executing: [new session: Capabilities [{browserName=chrome, version=, platform=ANY}]])
09:25:10.972 INFO [28] org.openqa.selenium.remote.server.DefaultDriverProvider - Creating a new session for Capabilities [{browserName=chrome, version=, platform=ANY}]
09:25:10.973 WARN [17] org.openqa.selenium.remote.server.DriverServlet - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'BLR-SOFT-195', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-96-generic', java.version: '1.8.0_101'
Driver info: driver.version: unknown
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:119)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:36)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:185)
at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:204)
at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:166)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:132)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:808)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:499)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:310)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.seleniumhq.jetty9.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'BLR-SOFT-195', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-96-generic', java.version: '1.8.0_101'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:113)
at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:97)
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:209)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
... 1 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:103)
... 9 more
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)
... 14 more
09:25:10.974 WARN [17] org.openqa.selenium.remote.server.DriverServlet - Exception: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Any help appreciated.
It seems a problem related to chromedriver.
The path to the driver executable must be set by the
webdriver.chrome.driver system property; for more information, see
https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest
version can be downloaded from
http://chromedriver.storage.googleapis.com/index.html
Where is your chromedriver located?
Which SO are you working in? Centos? Ubuntu? I recommend you to not run it in a cron. Instead you can create a service and see if it works:
Create a file in /etc/systemd/system/selenium-node.service
Add to the file:
[Unit]
Description=Run a selenium node
[Service]
ExecStart=/usr/bin/java -jar /route/to/selenium/selenium-server-standalone-2.52.0.jar -role node blablabla
Restart=on-abort
[Install]
WantedBy=multi-user.target
And run:
sudo systemctl daemon-reload
sudo systemctl start selenium-node.service
Or you can add sh /home/selenium/automation/nodeStartUp.sh at the end of the init.d file (but thats not the best option too).

PhantomJS or Selenium Standalone killed after first failed tests

I don't know if this is a Protractor or PhantomJS error.
I'm running this command, getting this log.
It seems like PhanthomJS or Selenium Standalone is dying after the fist fail test.
Do you need more logs/details to check where is the issue?
$ grunt accept:standalone --suite=list
Running "env:rde" (env) task
Running "shell:protractor_update" (shell) task
selenium standalone is up to date.
chromedriver is up to date.
Running "protractor_webdriver:start" (protractor_webdriver) task
Starting Selenium server
Started Selenium server: http://127.0.0.1:4444
Running "protractor:test" (protractor) task
Using the selenium server at https://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Session created: loggingPrefs=org.openqa.selenium.logging.LoggingPreferences#255d17d7, count=1, browserName=phantomjs, phantomjs.binary.path=c:\git\clients\special-offers\node_modules\phantomjs\lib\phantom\phantomjs.exe, version=ANY
Preparing new session
.FF
Failures:
1) Special Offers list page should have a thumbnail, a title, a description and a CTA
Message:
NoSuchElementError: No element found using locator: By.cssSelector(".ss .details p.body-copy")
2) sssssssssssssss
Message:
UnknownError: Error communicating with the remote browser. It may have died.
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'CBA-D013', ip: 'xxxxxx', os.name: 'Windows NT (unknown)', os.arch: 'amd64', os.version: '6.2', java.version: '1.6.0_26'
Driver info: driver.version: EventFiringWebDriver
Finished in 29.282 seconds
3 tests, 6 assertions, 2 failures
Session deleted: Keeping the Selenium server alive
c:\git\clients\special-offers\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113
var template = new Error(this.message);
^
>>
>> Test failed but keep the grunt process alive.
Running "shell:kill_selenium" (shell) task
Shutting down Selenium server: http://127.0.0.1:4444
Done, without errors.
Bye all!