Selenium UnreachableBrowserException - Java - java

System.setProperty("webdriver.chrome.driver","D:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://link");
driver.findElement(By.cssSelector("#username")).sendKeys("id");
driver.findElement(By.cssSelector("#password")).sendKeys("pass");
driver.findElement(By.cssSelector("#clientName")).sendKeys("name");
driver.findElement(By.cssSelector("#submitButton")).click();
System.out.println("Okay !");
I set property for Chrome Driver. When I run it gives an error. (Below) I searched a lot but didn't found any solution.
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 10589
Only local connections are allowed.
Exception in thread "main" 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: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z'
System info: host: 'DESKTOP-9HVORCR', ip: '192.168.1.24', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:564)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at zaaa.main.main(main.java:11)
Caused by: java.lang.IllegalArgumentException: Unexpected char 0x131 at 23 in User-Agent value: selenium/3.12.0 (java wındows)
at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:338)
at okhttp3.Headers$Builder.add(Headers.java:288)
at okhttp3.Request$Builder.addHeader(Request.java:177)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:85)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
... 6 more
I have tried these:
32/64 bit drivers.
Run it as administrator.
Creating a Try/Catch block.
Other drivers. (Like Operadriver.exe) (Result: Same error)

I think your windows is not english. I am having the same problem. When I tried the same in an english version windows 10 the code works without any problem.

Locale.setDefault(new Locale("en", "EN"));
you can also try this. it worked for me.

Add these lines before instantiating "WebDriver driver = new ChromeDriver();"
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
Then add the argument where you have declared Webdriver as shown below:-
WebDriver driver = new ChromeDriver(chromeOptions);
I hope it will help you.

Here you are using
selenium version : 3.12.0
chromedriver version : 2.40
When i tried to run with these configurations (they are latest at present)
I am able to launch the application without any exception and in the logs getting :
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 35584
Only local connections are allowed.
Jun 21, 2018 2:42:51 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Okay !
which is same as your starting logs.
My chrome browser version is :
Version 67.0.3396.87 (Official Build) (64-bit)
I think you should check your .m2 folder and delete
.m2\repository\org\seleniumhq\selenium
folder from there and then again try to download the dependencies.
Also update to latest chrome browser version.
Hope it helps.

This is a problem of Turkish Windows. As it is indicated in exception message the 'ı' character in user agent value "selenium/3.12.0 (java wındows)" is the cause of the exception.
The problem is the string "WINDOWS" is changed to lower case and it results "wındows" because of TR locale. I found that it is generated in class org.openqa.selenium.remote.http.HttpClientand added Locale.US like this.
String USER_AGENT = String.format(
"selenium/%s (java %s)",
new BuildInfo().getReleaseLabel(),
(Platform.getCurrent().family() == null ?
Platform.getCurrent().toString().toLowerCase(Locale.US) :
Platform.getCurrent().family().toString().toLowerCase(Locale.US)));
I compiled the library with my changes and it works now. I also opened a pull request on github.
You can also find my edited fork here.

Related

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 Chromedriver server times out despite being available

I have a Java Selenium project that will not run on my machine, but does run on coworkers' machines with the same OS version (OSX 10.13.1), Chrome browser version (63.0.3239.84), and chromedriver version (2.34). I get the message:
Starting ChromeDriver 2.34.522932 (4140ab217e1ca1bec0c4b4d1b148f3361eb3a03e) on port 18633
Only local connections are allowed.
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'localhost', ip: 'fe80:0:0:0:1cc9:e0ab:f4e5:dd34%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.1', java.version: '1.8.0_20'
Driver info: driver.version: ChromeDriver
...
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:18633/status] to be available after 20005 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:187)
... 28 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:149)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
... 29 more
however when I open http://localhost:18633/status in my browser I get a valid response:
{"sessionId":"","status":0,"value":{"build":{"version":"alpha"},"os":{"arch":"x86_64","name":"Mac OS X","version":"10.13.1"}}}
I've tried swapping out chromedriver binaries, but I'm not really sure what else to do. I get similar issues with geckodriver, but that may or may not be the same issue.
I have also tried creating a new user on my system and running it from that account, to account for user settings - No luck.
What am I missing here? What info would be helpful to debug this problem?
The error says it all :
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Clearly indicates the WebDriver instance didn't get initiated. Hence Driver info is left blank as :
Driver info: driver.version: ChromeDriver
Which inturn produces the error:
org.openqa.selenium.net.UrlChecker$TimeoutException
and
java.util.concurrent.TimeoutException
It would be tough to guess the actual reason without any visibility of your code block but in general we can solve this by downloading the ChromeDriver binary from this repository and passing the absolute path of the ChromeDriver while initializing the WebDriver instance as follows :
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
driver = new ChromeDriver();
Key Points :
Always use the latest version of the Selenium Client and ChromeDriver binaries.
Always keep the automatic updates for the browser enabled.
Always keep the JDK version updated (the current version being JDK 8u241)

Selenium not opening firefox with geckodriver 10.0 - unreachable browser exception

I am having some difficulties with Selenium opening Firefox. It works on my computer at home but I am not sure why it doesnt work on my work computer. Some help and guidance on this would be much appreciated because I am newbie to this tool and eclipse.
I have downloaded geckodriver 10 and am running Selenium 3 with Eclipse Neon. I imported the selenium-server-standalone-3.0.0-beta3 to the Java Build Path to my test Selenium project.
My code is as follows:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class openBrowser {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "D:\\JW\\Selenium\\geckodriver-v0.8.0-win32\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com");
}
}
When I run the program I get the following in the console:
Sep 30, 2016 10:42:18 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Exception in thread "main" 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: '3.0.0-beta3', revision: 'c7b525d', time: '2016-09-01 14:57:03 -0700'
System info: host: 'SBC-40489825', ip: '10.27.20.46', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_73'
I run the program but firefox never seems to open as the connection seems to be refused Any ideas whats wrong?
Best Regards
Tarquin
Try Marrionatedriver, it will use. Following is the code:
WebDriver driver = new MarrionateDriver();
I would suggest you don't use beta version until a final stable version of Selenium3 is not being released there may have many bugs which would be fix.
You should downgrade your selenium version to last stable version of Selenium2.
Because Selenium2 works well without using GeckoDriver to lunch Mozilla Firefox < v47, you should downgrade it as well below v47 to get rid from these issues until final version of Selenium3 is not being released.
This works
System.setProperty("webdriver.firefox.marionette",D:\\JW\\Selenium\\geckodriver-v0.8.0-win32\\geckodriver.exe);
This issue is specific to Geckodriver Windows32 bit.
GeckoDriver doesn't support Windows 32Bit, they are yet to release Geckodriver V0.11 version. You check version Milestone status
You can also check the discussion on this issue here last comments
Here is an article that explains this issue.
UPDATE : Geckodriver V0.11 version released. Please try use this version.

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.

Running Selenium 2.12 fails on Internet Explorer with Java

I have just installed the latest version of Selenium 2.12.
I am trying to run the following java program using Selenium on IE. But unfortunately it's not working.
sample program
Here is the error message.
May 24, 2012 7:12:50 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request
Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 849 milliseconds
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_04'
Driver info: driver.version: InternetExplorerDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:175)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:134)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:459)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:140)
at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:113)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:66)
at ExampleProgram.main(ExampleProgram.java:13)
This is launching the IE 8 with the URL "http://localhost:15194/" and showing the content - This is the initial start page for the WebDriver server.
Please help me with what I'm doing wrong here. I have done the basic setup as mentioned in wiki
Just a small correction, the latest version is 2.21 and not 2.12.
Start your scripts with this
driver = Selenium::WebDriver.for :ie, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate]
Open your browser as an Admin, and change settings in Internet Options to allow popups and also keep "Protected Mode"disabled.
Apart from that, I guess the modal message could also be because there might be some insecure content that is being displayed on a https site.
So to avoid that the message from being displayed, also perform the following steps
IE-> Open as Admin
Go to Internet Options
Go to Security tab
Click on Custom Level button
Under Miscellaneous - Enable Mixed content
if this does not solve the issue, please share the exact message that is displayed on the modal popup.
Hope this helps
This worked for me after installing the new IE version - 9.
You have to download "IEDriverServer_Win32_2.29.0.zip". Extract it to a target folder and instantiate the Internet Explorer browser as below:
File file = new File("E:\\Global Blue\\globalblue-selenium-test\\gb-selenium-test\\lib\\IEDriverServer_Win32_2.29.0\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver oWebDriver = new InternetExplorerDriver();
Try using:
Thread.sleep(3000);
It worked for me.

Categories