Selenium Not able to run Firefox browser from Jenkins - selenium

I tried running Automated test using selenium on firefox through jenkins on Ubuntu Machine but not able to run it. But the same code is running without failure using Eclipse. I am running it as maven project.
Getting following error-
"[INFO] Running TestSuite
1524549883598 geckodriver INFO geckodriver 0.20.0
1524549883615 geckodriver INFO Listening on 127.0.0.1:14395
1524549883939 mozrunner::runner INFO Running command: "/usr/lib/firefox/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.78vmBc1aqdpF"
1524549883941 geckodriver::marionette TRACE connection attempt 0/600
ExceptionHandler::GenerateDump cloned child 6290
ExceptionHandler::SendContinueSignalToChild sent continue signal to child
ExceptionHandler::WaitForContinueSignal waiting for continue signal...
1524549884041 geckodriver::marionette TRACE connection attempt 1/600
1524549884141 webdriver::server DEBUG <- 500 Internal Server Error {"value":{"error":"unknown error","message":"Process unexpectedly closed with status signal","stacktrace":""}}
Msg Process unexpectedly closed with status signal
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'Unknown', ip: 'Unknown', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-96-generic', java.version: '1.8.0_131'
Driver info: driver.version: FirefoxDriver
remote stacktrace:
Firefox version -60.0b10
Selenium -3.11.0
Using Gecko driver"

This error message...
1524549884141 webdriver::server DEBUG <- 500 Internal Server Error {"value":{"error":"unknown error","message":"Process unexpectedly closed with status signal","stacktrace":""}}
...implies that the marionette wasn't able to initiate an active connection with the WebClient i.e Firefox browser.
Your main issue is the version compatibility between the binaries you are using as follows :
Your Selenium Client version is 3.11.0.
Your JDK version is 1.8.0_131 which is pretty ancient.
Your GeckoDriver version is v0.20.0.
Your Firefox version is unknown to us.
So there is a clear mismatch between the JDK v8u131 , Selenium Client v3.11.0 and GeckoDriver v0.20.0.
Solution
Upgrade JDK to recent levels JDK 8u162.
Upgrade GeckoDriver to GeckoDriver v0.20.1 level.
Ensure that GeckoDriver is present in the specified location as per your code block.
Ensure that GeckoDriver is having executable permission for non-root users.
Upgrade Firefox version to Firefox v59.0.2 levels.
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 as a non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Related

Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException) error with Selenium and Geckodriver

Here's the situation: I'm using Behat to run acceptance tests on Symfony. To do so, I start a Selenium instance with the Geckodriver, then I run Behat. Everything works fine on local (great!).
But when it runs on Github action, it fails. I've check the versions, I've even versioned the geckodriver and selenium.jar files to use exactly the same (despite they already exist on github action), but nothing works.
So I'm looking for any help to debug this error. Here's the commands and their results:
$ java -jar -Dwebdriver.gecko.driver=/usr/local/share/gecko_driver /usr/share/java/selenium-server-standalone.jar &
14:19:46.106 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
14:19:46.369 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2020-05-29 14:19:46.780:INFO::main: Logging initialized #1350ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:19:47.657 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
14:19:47.758 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
./vendor/bin/behat -s acceptance
Could not open connection: Unable to create new service: GeckoDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'fv-az33', ip: '10.1.0.4', os.name: 'Linux', os.arch: 'amd64', os.version: '5.3.0-1022-azure', java.version: '1.8.0_252'
Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)
This error message...
Driver info: driver.version: unknown (Behat\Mink\Exception\DriverException)
...implies that the GeckoDriver wasn't recognized back by the Browsing Context i.e. Firefox browser.
Solution
Ensure that:
JDK is upgraded to current levels JDK 8u251.
Selenium is upgraded to current levels Version 3.141.59.
GeckoDriver is upgraded to GeckoDriver v0.26.0 level.
Firefox is upgraded to current Firefox v76.0 levels.
GeckoDriver is present in the desired location.
GeckoDriver is having executable permission for non-root users.
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 a non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Reference
You can find a couple of relevant discussions in:
Driver info: driver.version: unknown with ChromeDriver Chrome using Selenium and Python
Ok, I've just solved my problem. I think this is due to two things:
First, I was not using the headless mode. I don't know to set it using Geckodriver because I'm finally using Chromedriver
Second, the github action's doc is misleading. It says 'Chrome Driver is available via CHROMEWEBDRIVER environment variable', but in fact it's only the directory which is in the env var. So the path of the driver is $CHROMEWEBDRIVER/chromedriver (same for $GECKOWEBDRIVER)
For info, here's my config of behat:
javascript_session:
selenium2:
browser: chrome
capabilities:
chrome:
switches:
- "--headless"
- "--disable-gpu"
And to run Selenium:
java -Dwebdriver.chrome.driver=$CHROMEWEBDRIVER/chromedriver -jar $SELENIUM_JAR_PATH &

Showing Error - unknown error: DevToolsActivePort file doesn't exist - it's electron application (I am using windows OS))

When I run my code it's showing below error - Electron application
org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'DESKTOP-GN8LLQU', ip: '192.168.1.20', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: driver.version: ChromeDriver
My Code:
ChromeOptions opt = new ChromeOptions();
// path of your Electron Application
opt.setBinary("D:\\FOS\\fiber-optic-system-electron\\release\\angular-electron 0.1.0.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromeOptions", opt);
capabilities.setBrowserName("chrome");
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver_win32 (6)\\chromedriver.exe");
WebDriver driver = new ChromeDriver(capabilities);
I have been experiencing the error DevToolsActivePort file doesn't exist myself and in my case the error was correct and the root cause was the electron app itself.
Since v2.39 Chrome's web driver (chromedriver.exe) by default looks for a file named DevToolsActivePort and when found reads it to obtain the port number of devtools that is currently running in chrome (and in your case the Chrome instance that the electron app "angular-electron 0.1.0.exe" is running).
When you create a ChromeDriver in Selenium and include the --remote-debugging-port=0 argument, or otherwise do not include this argument at all, then chromedriver will send --remote-debugging-port=0 in the command line to your electron app (ie. angular-electron 0.1.0.exe). If your electon app passes this argument onto the Chrome app running inside it then the DevToolsActivePort file is created, chromedriver can read it and gain the port of devtools, and automation is successful. However if your electron app does not pass this argument to Chrome then the DevToolsActivePort file is never created and your chromedriver times out looking for it and fails.
You have a couple of options for a solution:
Have the developers of the electron app ensure the "--remote-debugging-port" argument is passed onto Chrome.
Automate your own solution for creating the "DevToolsActivePort" file.
In my case I went with option 2. Here's how you can test this option manually. If you run an application like SysInternal's Tcpview (https://learn.microsoft.com/en-us/sysinternals/downloads/tcpview) before your electron app then Tcpview will show you the ports that your electron app is listening on. One of these ports will be the Chrome's devtools port. Note this down. Now go into your %temp% folder in Windows as this is the default location for the temporary folder containing the DevToolsActivePort file that chromedriver is looking for. In this folder look for the folders prefixed with scoped_dir. By default chromedriver will create one these each time you run it. To guarantee you access the correct folder it's best to set this directory name yourself beforehand in chromedriver using the --user-data-dir argument before running it. Go into this folder and create a new file named DevToolsActivePort and enter the port number on the first line, press Enter (newline), and then any number on the second line. Save the file and close. If you complete this entire process manually within 60 seconds the running chromedriver will read that file, get the port of Chrome's devtools, connect to it and continue.
I have developed an AutoIT script that does the above process automatically and I include this in my own automation runs and works every time.
Hope this helps.
This error message...
org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'DESKTOP-GN8LLQU', ip: '192.168.1.20', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: driver.version: ChromeDriver
...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:
Possibly you are using the latest chromedriver=77.0
Possibly you are using_chrome= 77.0_
Your Selenium Client version is 3.6.0 of 2017-09-27T15:28:36.4Z which is almost 2 years older.
Your JDK version is 11.0.2.
So there is a clear mismatch between the Selenium Client v3.6.0 , ChromeDriver v77.0 and the Chrome Browser v77.0
Solution
Ensure that:
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.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Note: As per Unable to import org.openqa.selenium.WebDriver using Selenium and Java 11 it may be a better idea to downgrade to Java 8
Outro
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
Although this is an old question but want to add my answer here, it may help someone.
My environment was [ When I can see the same error ] :
Windows 10
Selenium 3.14
Chrome driver 85.0.4183.87
Browser version for electron app is 85.0.4183.121
[ Sidenote : I am trying to automate Microsoft Teams and it is an electron app ] .
After searching a lot through internet came to conclusion that it is somehow a version mismatch . Finally this github issue link backed my theory and the ChromeDriver 2.37.544315 attached in its answer worked for me.
My code is similar to what we see in the SO question.
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:\\Users\\<MyUserName>\\AppData\\Local\\Microsoft\\Teams\\current\\Teams.exe");
WebDriver driver = new ChromeDriver(opt);
and output is [ As expected : Teams opens up without any error ]:
Starting ChromeDriver 2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7) on port 2389
Only local connections are allowed.
Jan 12, 2022 1:23:57 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

ChromeDriver crashes and does not create a session when chrome is already open in selenium-jvm

There are two parts of this problem -
When a chrome browser is already open and I trigger my selenium-java test case to run against the chrome it doesn't open a new chrome session.
It uses the existing chrome which is open and starts opening new tabs but still doesn't work.
My driver initialization looks like as below :
System.setProperty("webdriver.chrome.driver", ConfigUtils.getCurrentDirectory()+ Chromefile.getPath());
ChromeOptions options = new ChromeOptions();
//options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("disable-extensions");
options.setExperimentalOption("useAutomationExtension", false)
driver = new ChromeDriver(options);
I have tried couple of things suggested on Stack Overflow -
Someone described that this is a problem because chromedriver cannot spin up another instance of chrome - default profile. So I have added the following line in the above code -
String profile1 = "C:\\Users\\user_id\\Documents\\ChromeProfile1\\";
options.addArguments("user-data-dir="+profile1);
This was done so that chromedriver could launch a new profile of chrome. And it does open a new chrome window but didn't navigated to the URL.
As per the official documentation of chromedriver -
By default, ChromeDriver will create a new temporary profile for each
session.
And I never has to do this before. I am not sure why this is not working and what else can I do?
I am using -
Selenium-java version 3.141.1
ChromeDriver version 2.38
Chrome version 70
Windows 10
Please note-
The chrome and chromedriver version I have mentioned above are compatible and working fine when chrome is not already running Also, I can run the same test in headless mode while chrome window is already open.
let me know if you need anymore info. Error I am getting is as below-
Starting ChromeDriver 2.38.552522
(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb) on port 18020 Only local
connections are allowed. org.openqa.selenium.WebDriverException:
unknown error: Chrome failed to start: crashed (Driver info:
chromedriver=2.38.552522
(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT
10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 61.87 seconds Build info:
version: '3.141.5', revision: 'd54ebd709a', time:
'2018-11-06T11:42:16' System info: host: 'XXXX', ip: 'XXXX', os.name:
'Windows 10', os.arch: 'x86', os.version: '10.0', java.version:
'1.8.0_162' Driver info: driver.version: ChromeDriver
ChromeDriver 2.38 only supports Chrome 65 through 67. Please see the release notes at https://chromedriver.storage.googleapis.com/2.38/notes.txt. It may happen to work with some other versions of Chrome under certain conditions, but such usage is unsupported. It is recommended to use ChromeDriver 2.44 with Chrome 70.
I don't see any problems with the code you posted. Hopefully you'll be able to get better results after downloading a newer ChromeDriver.

Which Selenium standalone version is compatible with Firefox version 58.0

Which Selenium standalone jars are compatible with Firefox version 58.0?I tried 2.46.0 selenium jars and I am getting this exception:
org.openqa.selenium.WebDriverException:
Unable to bind to locking port 7054 within 45000 ms
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: 'CHDSEZ400598D', ip: '10.152.107.68', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_77'
Mozilla Firefox Browsers are released as GA (General Availability) versions irrespective of Manual or Automation testing. It's the GeckoDriver which controls the Mozilla Firefox Browser through Marionette. Again its the Selenium Client which initializes the GeckoDriver. So the compatibility rests partially with Selenium Client and partialy with GeckoDriver.
Though Selenium releases are made with outmost effort to keep the Selenium Clients backward compatible with the previous releases of GeckoDriver and Firefox Browser releases but the last dependency announced as per the Selenium Release Notes is as follows :
v3.4.0
======
* Geckodriver 0.16 is strongly recommended
The last announced dependency of GeckoDriver 0.19.0 (2017-09-16) is as follows :
0.19.0 (2017-09-16)
Note that with geckodriver 0.19.0 the following versions are recommended: - Firefox 55.0 (and greater) - Selenium 3.5 (and greater)
Solution
An effective solution would be as follows :
Update your JDK version to the latest version, currently vJDK 8u162
Update your Selenium Client version to the latest version, currently v3.10.0
Update your GeckoDriver version to v0.19.1 (2017-10-30)
Update your Firefox Quantum Browser version to [v58.0.2]
Clean your Project Workspace 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 Firefox version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Firefox.
Execute your #Test.

Unable to run the selenium script while connected to the LAN

Unable to run the selenium script while connected to the LAN, however it works fine when connected to the WIFI. I have kept all the proxy settings same.
Below is the code:
String exePath = "/usr/local/bin/chromedriver";
System.setProperty("webdriver.chrome.driver", exePath);
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
OS: Mac 10.11.6
Selenium: 2.53
Also tried with 3.8.1
ChromeDriver: 2.33.2
Chrome: V60.
Eclipse Oxygen.
Getting Below mentioned error message:
Starting ChromeDriver 2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2) on port 21777
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception
from disconnected: unable to connect to renderer
(Session info: chrome=60.0.3112.113)
(Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.65 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: '01hw382197', ip: '172.25.155.171', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '9.0.4'
Driver info: org.openqa.selenium.chrome.ChromeDriver
The error says it all :
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception
from disconnected: unable to connect to renderer
(Session info: chrome=60.0.3112.113)
(Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.65 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
The main reason is the binaries you are using are incompatible as :
You are using ChromeDriver v2.33 of (2017-10-03)
Your Chrome Browser version is 60.x
Your Selenium Client version is 2.53.1 of time: '2016-06-30 17:32:46'
So there is a time gap of almost 2 years between the release of Selenium Client v2.53.1 and ChromeDriver v2.33
Solution
Upgrade your Selenium Client to recent Selenium v3.9.1 level.
Upgrade your ChromeDriver to recent ChromeDriver=2.35 level.
As per the Release Notes of ChromeDriver=2.35 upgrade your Chrome Browser to Chrome v62-64 levels.
If your base Chrome Browser version is too old uninstall Chrome Browser through Revo Uninstaller and install a recent released GA version of Chrome Browser
Run CCleaner tool regularly to wipe off all the OS chores before and after the execution of your Test Suite
Execute your Tests
Update
As you mentioned you are unable to run the script while connected to the LAN but works fine when connected to the WIFI you need to ensure the following :
Ports used by the WebDriver variants (GeckoDriver / ChromeDriver / IEDriverServer) are not used by any other Software/Services over the LAN.
Ports (range of ports) are not blocked by the LAN Admins for specific purpose.
Firewall is disabled.