Selenium, Firefox and GeckoDriver - java

I have a question and a problem.
Question:
By using Selenium 3.4.0 what is the latest version of Firefox that doesn't require GeckoDriver to run tests. Because using Firefox 45 i can run tests without GeckoDriver, although i thought it is required.
Problem:
I'm trying to use Firefox latest version 53.0, Selenium 3.4.0 and GeckoDriver 0.16.0
I set Firefox to the PATH. I set the path properties for Gecko as follows in this class: enter image description here
, Stack trace:
1493481035911 geckodriver INFO Listening on 127.0.0.1:32281 1493481036538 geckodriver::marionette INFO Starting browser \\?\C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette"] 1493481037661 addons.manager ERROR startup failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFile.create]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70" data: no] Stack trace: FileUtils_getDir()#resource://gre/modules/FileUtils.jsm:70 < FileUtils_getFile()#resource://gre/modules/FileUtils.jsm:42 < validateBlocklist()#resource://greJav/amSocdruilpets /eArdrdoorn:M arnageers.ojusrmc:e6:7/1/ g<r es/tmaordtuulpe(s)/#ArdedsoonuMracnea:g/e/rg.rjes/mm,o dluilnees /1A6d5d7o:n MNaSn_aEgReRrO.Rj_sNmO:T_INIT8I3A4L I<Z EsDt:a rAtdudpo(n)M#arneasgoeurr cies: /n/ogtr ei/nmiotdiualleized
s/AddonManager.jsm:3129 < observe()#resource://gre/components/addonManager.js:65
[GFX1]: Potential driver version mismatch ignored due to missing DLLs 0.0.0.0 and 0.0.0.0
1493481041925 Marionette INFO Listening on port 54083
JavaScript error: resource://gre/modules/AddonManager.jsm, line 2570: NS_ERROR_NOT_INITIALIZED: AddonManager is not initialized
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions#150c158, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile#4524411f}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '8c03df6', time: '2017-03-02 09:30:17 -0800'
System info: host: 'DESKTOP-HUOROU4', ip: '192.168.43.167', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:293)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:272)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:267)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:130)
at Test.main(Test.java:11)

Let me try to address your question one by one:
By using Selenium 3.4.0 what is the latest version of Firefox that doesn't require GeckoDriver to run tests - With Selenium 3.4.0 you can use Mozilla Firefox 47.x without gecko driver. From Mozilla Firefox 47.x on-wards gecko driver is mandatory.
With Selenium 3.4.0, geckodriver v0.16.1 & Mozilla Firefox 53.0 this piece of code works fine:
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(dc);
driver.get("http://google.com/");
Moreover, if you are using any extensions in your default Firefox profile either you need to disable/delete them or create a new Firefox profile for your automation work.
Let me know if this helps you.

Related

org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start with Selenium and Java

I have tried everything that has been told in Stackoverflow topics. I have java selenium tests run on remote slave through jenkins. The absurd thing is first test always run and browsers opens, all other tests give me "Timed out waiting for driver server to start".
public WebDriver startChrome() {
System.setProperty("java.net.preferIPv4Stack", "true");
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--aggressive-cache-discard");
chromeOptions.addArguments("--disable-cache");
chromeOptions.addArguments("--disable-application-cache");
chromeOptions.addArguments("--disable-offline-load-stale-cache");
chromeOptions.addArguments("--disk-cache-size=0");
chromeOptions.addArguments("--dns-prefetch-disable");
chromeOptions.addArguments("--no-proxy-server");
chromeOptions.addArguments("--log-level=3");
chromeOptions.addArguments("--silent");
chromeOptions.addArguments("--disable-browser-side-navigation");
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
chromeOptions.addArguments("-disable-cache");
chromeOptions.addArguments("-disable-extensions");
chromeOptions.addArguments("--incognito");
chromeOptions.addArguments("start-maximized");
//chromeOptions.setExperimentalOption("useAutomationExtension", false);
ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
port = chromeDriverService.getUrl().getPort();
return new ChromeDriver(chromeDriverService, chromeOptions);
}
Error:
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:231)
at org.openqa.selenium.remote.service.DriverService.lambda$start$0(DriverService.java:193)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:35592/status] to be available after 20000 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:90)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:227)
... 7 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:88)
... 8 more
All the solutions I have tried so far:
Update Java 1_8_271
Update Selenium 4
Update ChromeDriver 87
Check localhost traffic with rawcap
Check localhost dns definiton in etc/hosts
Update Chrome 87
Set Proxy
Check port availability
Check driver path
Kill all chrome and driver tasks before create (Only solution that worked, but not good for parallel tests)
Check localhost url and port is accessible with chrome -> http 200
When I try to reach url and port through java urlconnection in code driver create function catch block), it gives me connection reset but in chrome it gives 200.
All help will be appreciated.
Best Regards
This error message...
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
A bit of more information about your usecase would have helped us to analyze the error in a better way. However to start with you can use only one single arguments start-maximized and remove all the other arguments which would get you started. So your effective code block will be:
public WebDriver startChrome() {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("start-maximized");
ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
return new ChromeDriver(chromeDriverService, chromeOptions);
}
Additional Consideration
Ensure that:
JDK is upgraded to current levels JDK 8u271.
Selenium is upgraded to current released Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v87.0 level.
Chrome is updated to current Chrome Version 87.0 level. (as per ChromeDriver v87.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.
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.
References
You can find a couple of relevant detailed discussions in:
Selenium Chromedriver server times out despite being available
Driver info: driver.version: unknown with ChromeDriver Chrome using Selenium and Python
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start while initiating Chrome browser through Selenium

org.openqa.selenium.WebDriverException: unknown error: cannot find MSEdge binary error using EdgeDriver and Selenium on Mac through Java

I have trouble running MS Edge test on MAC using Selenium Remote web driver.
I tried to set System property for edge binary as below:
dc = DesiredCapabilities.edge();
System.setProperty("webdriver.edge.driver", "/Users/username/Softwares/Work/jars/msedgedriver");
dc.setCapability("edge_binary","/Applications/Microsoft Edge Beta.app");
I checked that msedge driver version and version of MS Edge browser that I have installed.
Both are - 80.0.361.48
This is the log on Selenium node:
020-02-11 18:06:37.533:INFO:osjshC.ROOT:qtp1800659519-12: org.openqa.selenium.remote.server.WebDriverServlet-59309333: Initialising WebDriverServlet
18:06:37.551 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession#47c6497e
18:06:37.555 INFO - /session: Executing POST on /session (handler: BeginSession)
18:06:37.632 INFO - Capabilities are: Capabilities {MicrosoftEdge_binary: /Applications/Microsoft Edg..., browserName: MicrosoftEdge, platform: MAC, version: }
18:06:37.633 INFO - Capabilities {MicrosoftEdge_binary: /Applications/Microsoft Edg..., browserName: MicrosoftEdge, platform: MAC, version: } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.edge.EdgeDriverService)
Starting MSEdgeDriver 80.0.361.48 (e1a3ff36578e440880567e6adcbeab38ec2956fa) on port 31883
Only local connections are allowed.
Please protect ports used by MSEdgeDriver and related test frameworks to prevent access by malicious code.
Exception that I get when running code is as
org.openqa.selenium.WebDriverException: unknown error: cannot find MSEdge binary
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: '****-MacBook-Pro.local', ip: 'fe80:0:0:0:14d9:68c6:7d2c:87a%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.2', java.version: '1.8.0_152'
Driver info: driver.version: unknown
This error message...
org.openqa.selenium.WebDriverException: unknown error: cannot find MSEdge binary
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: '****-MacBook-Pro.local', ip: 'fe80:0:0:0:14d9:68c6:7d2c:87a%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.2', java.version: '1.8.0_152'
Driver info: driver.version: unknown
...implies that the program was unable to locate MSEdge binary within your system.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Though you are using compatable versions of MS Edge Driver v80.0 and MS Edge Browser v80.0
Your Selenium Client version is 3.7.1 of 2017-11-06T21:07:36.161Z which is almost 2.5 years older.
But your JDK version is 1.8.0_152 which is pretty ancient.
So there is a clear mismatch between JDK v8u152 , Selenium Client v'3.7.1 , MS Edge Driver v80.0 and the MS Edge Browser v80.0
Solution
Ensure that:
JDK is upgraded to current levels JDK 8u241.
Selenium is upgraded to current levels Version 3.141.59.
Take a System Reboot.
Execute your #Test as non-root user.

org.openqa.selenium.WebDriverException: chrome not reachable - when attempting to start a new session

When I run my tests on Chrome I often get a WebdriverException that Chrome is not reachable. It doesn't happen every time. Maybe once every 15 times. I am having to run everything on Windows machines and I have the latest Chrome, Chromedriver, Selenium-Webdriver versions.
I've tried setting the environmental variable "DBUS_SESSION_BUS_ADDRESS=/dev/null". Doesn't help at all.
Anyone come across this and found a solution?
org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 62.52 seconds
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'CORPMNA7158A', ip: '10.26.195.163', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.chrome.ChromeDriver
The error does gives us some hint as follows :
org.openqa.selenium.WebDriverException: chrome not reachable
Which essentially implies that chromedriver binary is unable to spawn a new Chrome Browser process.
Your main issue is the version compatibility among the binaries you are using as follows :
You are using chromedriver=2.35.528161 (released 2018-01-10)
Release Notes of chromedriver=2.35 clearly mentions the following :
Supports Chrome v62-64
You mentioned of using latest Chrome. I suppose it is chrome=65.x
You are using Selenium Version 2.52.0 (released 2016-02-11 11:22:43) [as per the error stack trace within your question]
So the time gap between the release of Selenium Version 2.52.0 and chromedriver=2.35.528161 is almost 2 Years and are not compatible. Hence ChromeDriver is unable to spawn the new Chrome Browser process at times.
Solution
Keep the ChromeDriver at v2.35 level.
Downgrade Chrome to stable Chrome v64.x levels. (as per ChromeDriver v2.35 release notes)
Upgrade Selenium to current levels Version 3.8.1.
Execute your Test.

Selenium test case script with JUnit is not working on eclipse for Firefox driver

I have tried with all version of Firefox 45, 48, 49, and 50. I also have to mention the path for the Gecko driver (64 bit) in my program, but still the Firefox browser is not opening once I run my program. I am using Selenium 3.0.1 Java version.
Here is my code:
System.setProperty("webdriver.gecko.driver", "C:\\Users\\Desktop\\ecpipse2\\Selenium Library files\\geckodriver.exe");
driver = new FirefoxDriver();
baseUrl = "http://automationpractice.com/index.php";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
The following error is coming:
org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:45120 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'LAPTOP-C07CIJJB', ip: '192.168.0.6', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
If the Gecko driver version is not correct then it doesn't establish a connection with Firefox.
In the above question, the mentioned error was a little bit confusing which doesn't say about Gecko driver is not compatible with the Selenium web driver and Firefox version.
My case now: It's working fine with Firefox 49.0.2, Selenium webDriver 3.0.1, and Geckodriver.exe 0.11.1.
You can see a working example here.
The following combination worked fine for me:
Firefox: 50
selenium-java: 3.0.1
JUnit: 4.12
geckodriver.exe: 11.1

Selenium WebDriver upgrade results in UnreachableBrowserException

I recently found that my Selenium Java libraries were not working. Version 2.48.2 would open a Firefox window and then "stall" with no error within Netbeans nor Firefox itself before returning from new FirefoxDriver(). I figured that this version of Selenium might be broken so I found the latest Java libraries (Version 2.53.1) and have been trying to get them to work.
My issue now is almost the same but with two errors. The first is thrown by Netbeans when trying to execute new FirefoxDriver().
Exception in thread "AWT-EventQueue-0" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: 'MrComputer', ip: '192.168.0.101', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
...
The second is from Firefox itself. The window opens but instantly encounters the error.
Problem signature:
Problem Event Name: APPCRASH
Application Name: firefox.exe
Application Version: 47.0.0.5999
...
The code I am using is quite simple. Just the line
WebDriver driver = new FirefoxDriver();
I am by no means an extremely knowledgeable Selenium user so I am not sure what other information I could provide that might be of help.
EDIT: It seems that my Firefox version was not high enough to use the 2.53.1 Selenium libraries. My version of 47.0.0.5999 needed to be at least 47.0.1.
Prior to this, version 2.53.0 did need to make use of the MarionetteDriver as per this SO answer.
Unfortunately Selenium WebDriver 2.53.0 is not compatible with Firefox
47.0. The WebDriver component which handles Firefox browsers (FirefoxDriver) will be discontinued. As of version 3.0, Selenium
WebDriver will have MarionetteDriver as the default running
implementation for Firefox tests.
...
UPDATE
Selenium WebDriver 2.53.1 has been released on 30th June 2016.
FirefoxDriver is working again with Firefox 47.0.1 as browser.
For Selenium 2.53.1 the Firefox version needs to be at least 47.0.1. Updating my Firefox did the trick.
EDIT: It also seems that version 47.+ was not released to the Ubuntu archives for a few weeks after the Windows version.

Categories