Selenium RemoteWebDriver UnreachableBrowserException with Edge - java

Hi I've been working on a side-project using Maven and a TestNG Framework. So far my code works well with WebDriver instances (Chrome, Firefox, Edge), but I keep getting errors when attempting to set up a RemoteWebDriver with Edge. Here is how I have my Driver class(Implementing WebDriver Class) set up: (Showing the constructor portion with initializing Driver through RemoteWebDriver:
Edits:
public Driver (String browserName) {
this.browserName = browserName;
....
if(browserName.equalsIgnoreCase("edge")) {
System.setProperty("webdriver.edge.driver","./resources/webdrivers/MicrosoftWebDriver.exe");
DesiredCapabilities browser = DesiredCapabilities.edge();
browser.setPlatform(Platform.WIN10);
try {
this.driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), browser);
} catch (MalformedURLException e) {
e.printStackTrace();
}
js = (JavascriptExecutor) driver;
bugCapture = (TakesScreenshot)driver;
testFailDir = newFailCapDir();
}
When running the code with mvn and setting -Dbrowser=edge, this is the error I receive:
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.7.1', revision: '8a0099a', time: '2017-11-
06T21:01:39.354Z'
System info: host: 'LAPTOP-L1BFDSGL', ip: '10.0.0.11', os.name: 'Windows
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_162'
Driver info: driver.version: Driver
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to
localhost:17556 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed:
Connection refused: connect
Caused by: java.net.ConnectException: Connection refused: connect
After some research, I thought the problem was that I didn't have the Selenium-server-standalone jar file, it seems to call on the Maven Dependencies of Selenium jar files. I've looked around on this site and others to find the solution to my problem, but I'm still getting the same error. Is there a file I'm missing or can RemoteWebDriver be applied with Edge driver?
Any advice would help in this situation.
Thanks.
Update
#DebanjanB's request, The hub I used was during the declaration. After some research I didn't realize that I didn't have to have a hub or node active. (Probably why I was getting unreachable exception.) I also checked that I could set up a hub and node(I used port -5555 for node role). Commands I used for Hub and Node in separate cmd prompts:
java -jar selenium-server-standalone-3.10.0.jar -role hub
java -jar selenium-server-standalone-3.10.0.jar -role node -hub
http://localhost:4444/grid/register -port 5555
I also updated my maven dependencies to include to Selenium server standalone.
The maven I was running for my test was:
mvn test -Dbrowser=edge -Dgroups=<specified group>
When I ran with the hub running I was getting this exception error:
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.10.0', revision: '176b4a9', time: '2018-03-
02T19:03:16.397Z'
System info: host: 'LAPTOP-L1BFDSGL', ip: '10.0.0.11', os.name: 'Windows
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_162'
Driver info: driver.version: Driver
Caused by: java.net.ConnectException: Failed to connect to /10.0.0.11:4444
Caused by: java.net.ConnectException: Connection refused: connect
Before the failure I saw this message:
Mar 09, 2018 7:05:25 PM org.openqa.selenium.remote.DesiredCapabilities
edge
INFO: Using new EdgeOptions() is preferred to
DesiredCapabilities.edge()
//Error about test cases failed and skipped
#DebanjanB let me know if you need more clarification.
Update:
I managed to get my Remote Webdriver working using Edge. I had to mention the Dwebdriver I was going to use when registering my Node after setting up my hub.
Registering my Node:
java -Dwebdriver.edge.driver=MicrosoftWebDriver.exe -jar selenium-server-standalone-3.10.0.jar -role node -hub http://localhost:4444/grid/register -port 5555
(And I had add the physical driver as well for the path since when running on local drivers, I placed them in a different path.)
In my Driver class (I had to set my URL to my node instead of my hub):
System.setProperty("webdriver.edge.driver","./resources/webdrivers/MicrosoftWebDriver.exe");
DesiredCapabilities browser = DesiredCapabilities.edge();
try {
driver = new RemoteWebDriver(new URL("http://10.0.0.19:5555/wd/hub"), browser);
} catch (MalformedURLException e) {
e.printStackTrace();
}
Now when I run the command for edge without issue. :)

The error gives us some hint as follows :
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.
The error seems to be coming out of the line :
browser.setBrowserName(DesiredCapabilities.edge().getBrowserName());
As per your code block, browser is an instance of DesiredCapabilities Class and as per the documentation of setBrowserName() method it is defined as :
public void setBrowserName(java.lang.String browserName)
The edge() method from DesiredCapabilities Class helps us to cast the DesiredCapabilities object but doesn't contain any method e.g. getBrowserName() as such. So the following expression raises an error :
DesiredCapabilities.edge().getBrowserName()
As per the current release of Selenium v3.10.0, casting the DesiredCapabilities object with either chrome(), firefox(), internetExplorer() or edge() would automatically set the BrowserName and won't be needed to be explicitly mentioned.
Update
You need to send proper commands to start the Selenium Grid Hub and Selenium Grid Node.
For the error you are seeing org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session check the discussion RemoteWebDriver throws “org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session”
For a complete workflow check the discussion IE11 test runs if specified direct node ip but fails when grid hub url specified

Related

Selenium unable to connect to ChromeDriver 75 on Mac

We are upgrading a previously-working Selenium/Java/Chrome test configuration, to newer versions:
ChromeDriver 2.35 -> 75.0.3770.90
Selenium Java 3.14 -> 3.141.59
macOS 10.14.5 (unchanged)
Java 11.0.3 (unchanged)
Chrome 75.0.3770.100 (unchanged)
However, when attempting to run a Selenium test, we see:
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:28719
The full stack/log:
Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590e025-refs/branch-heads/3770#{#1003}) on port 28719
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Jun 26, 2019 10:45:03 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
...
org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:28719
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'Craigs-iMac.local', ip: '192.168.1.131', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.5', java.version: '11.0.3'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByTagName(RemoteWebDriver.java:396)
at org.openqa.selenium.By$ByTagName.findElement(By.java:320)
All the resources I've found in this area suggest using --whitelisted-ips='', which did not have an effect, or were related to incompatible Selenium/Chrome/ChromeDriver versions, which I don't think is the issue here.
Update: I can confirm that the driver starts, and is listening on port 28719, but then stops at some point between startup and execution of the actual test. I've found no errors/logging related to the shutdown.
Update 2: I've debugged, and the initial commands sent to the remote driver succeed (setWindowSize()), but this line causes the driver to die silently:
((WebStorage) driver).getLocalStorage().setItem("token", token);
It seems newer versions of the ChromeDriver (Or Selenium? I don't know.) launch Chrome with an initial page sitting at the URL data:.
By adding these system properties prior to instantiating the ChromeDriver:
System.setProperty("webdriver.chrome.logfile", "/Users/craig/chromedriver.log");
System.setProperty("webdriver.chrome.verboseLogging", "true");
I was able to glean the following right before the driver quits:
[1561563455.971][INFO]: [01517094c63c0dd609c06a5622afe6b1] RESPONSE ExecuteScript ERROR <unknown>: Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs.
(Session info: headless chrome=75.0.3770.100)
So by changing this call in my test utility code:
((WebStorage) driver).getLocalStorage().setItem("token", token);
To this:
if (driver.getCurrentUrl().startsWith("data:")) {
// Driver will quit if we try to access localStorage without a page load
driver.get("/");
}
((WebStorage) driver).getLocalStorage().setItem("token", token);
Everything is now fine. https://i.imgur.com/edBQBeJ.gif
Editing:
LocalStorage is available only after launching any website. ie after driver.get
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/html5/LocalStorage.html

SessionNotCreatedException: session not created exception from unknown error: Runtime.executionContextCreated has invalid 'context' with Chrome driver

Error stack trace (Updated from comments):
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 7778 Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"961185F0AA38D24650EF6C797BC32535","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"}
(Session info: chrome=70.0.3538.102)
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.68 seconds Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:41'
System info: host: 'LTAH024', ip: '192.168.131.142', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'
Driver info: driver.version: ChromeDriver
I wrote simple program to launching a chrome browser. Please see the below code. I have already set a path in environment variable:
package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ChromeBrowser {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver drive = new ChromeDriver();
drive.get("http://toolsqa.com/selenium-webdriver/running-tests-in-chrome-browser/");
System.out.println("Successfully open tools qa website in Chrome browser");
//Thread.sleep(5000); //To initiate thread , we need to add throws interrupt exception
//Close the driver
//driver.quit();
}
}
Please look into this and help me out. The same thing geckodriver for firefox is working.
This error message...
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 7778 Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"961185F0AA38D24650EF6C797BC32535","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"}
(Session info: chrome=70.0.3538.102)
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.68 seconds Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:41'
System info: host: 'LTAH024', ip: '192.168.131.142', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'
Driver info: driver.version: ChromeDriver
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
You have 3 issues exactly and your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.2.20
Release Notes of chromedriver=2.20 clearly mentions the following :
Supports Chrome v43-48
You are using chrome=70.0
Release Notes of ChromeDriver v2.43 clearly mentions the following :
Supports Chrome v69-71
Your Selenium Client version is the current version of 3.141.5..
Your JDK version is 1.8.0_60 which is pretty ancient.
So there is a clear mismatch between the JDK v8u60 , Selenium Client v3.141.5 , ChromeDriver v2.20 and the Chrome Browser v70.0
Solution
While using Selenium v3.x clients you need to download the latest ChromeDriver from ChromeDriver - WebDriver for Chrome store it anywhere within your system and provide the absolute path of the ChromeDriver through System.setProperty() line as follows:
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
Upgrade JDK to recent levels JDK 8u191.
Upgrade ChromeDriver to current ChromeDriver v2.43 level.
Keep Chrome version between Chrome v69-71 levels. (as per ChromeDriver v2.43 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
(WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
(LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint 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.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Download chrome driver, keep it at your local and put the path at System.setProperty try the below code, hope it helps.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ChromeBrowser {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "B:\\chromedriver.exe"); //put driver path here
WebDriver drive = new ChromeDriver();
drive.get("http://toolsqa.com/selenium-webdriver/running-tests-in- chrome-browser/");
System.out.println("Successfully open tools qa website in Chrome browser");
drive.quit();
}
}
Their are Three Ways to open The Chrome Browser:
First one:using system.setproperty
System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");
Webdriver driver = new ChromeDriver();
Second one : using Chrome Options:
//set path to chromedriver.exe
ChromeOptions options = new ChromeOptions();
options.setAcceptInsecureCerts(true);
options.setBinary(new File("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"));
options.addArguments("disable-infobars");
System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");
driver = new ChromeDriver(options);
Last one : if you are using maven use this
This downloads the latest chrome driver version and starts it. You can use WebDriverManager within using bonigarcia dependency. Add The bonigarcia dependency in your Pom.xml File and start using it via WebdriverManager
https://github.com/bonigarcia/webdrivermanager
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
Finally What is Version for your Gecko driver & Firefox?

Chromedriver failing on Jenkins (Linux)

I am trying to run UI tests on Chrome on Jenkins, and from the error it appears that it is failing to start.
org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Linux 2.6.32-358.el6.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.54 seconds (user: 'UnknownUser-0', output: '1440016601647')
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'abc.xyz.com', ip: '111.222.333.444', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-358.el6.x86_64', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:139)...
The code (in Java) simply tries to instantiate a default instance of Chromedriver, and fails. The following message also shows in the log, which confuses me. It appears that the driver is opening, but stopping immediately?
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 4601
Only local connections are allowed.
[0.422][WARNING]: PAC support disabled because there is no system implementation
Starting ChromeDriver 2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf) on port 9515
Only local connections are allowed.
The instantiation is done as:
WebDriver webDriver = null;
String chromeDriverLocation = MyCustomPropertyReader.getProperty("webdriver.chrome.binary.location");
System.setProperty("webdriver.chrome.driver", chromeDriverLocation);
final DesiredCapabilities capabilities = DesiredCapabilities.chrome();
webDriver = new ChromeDriver(capabilities);
I am able to run the Chromedriver from the command prompt, and I have also checked that all the environment variables that are needed to load it up and indeed available during the instantiation.
Could someone tell me what I might be missing, or if there is a way to obtain more information about the cause of this failure?
The issue was resolved by updating the browser installation, and making sure that both Chromedriver and the Chrome browser can be run from the command prompt.

Selenium UnreachableBrowserException - "Could not start a new session" in SoapUI Groovy TestStep

I use SoapUI Pro 5.1.2 on Win7 x32, and try to connect to Selenium Webdriver in Groovy TestStep.
For this purpose I added selenium-standalone-server.jar v2.45.0 in $SOAP_HOME$\bin\ext folder.
My Groovy TestStep code:
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
System.setProperty('webdriver.chrome.driver', 'C:\\\\Windows\\system32\\chromedriver.exe')
log.info(System.getProperty('webdriver.chrome.driver')) //got 'C:\\Windows\system32\chromedriver.exe'
WebDriver driver = new ChromeDriver() // this line causes error
driver.get('http://google.com')
driver.quit()
When I try to run this step, SoapUI returns message:
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.45.0',
revision: '5017cb8',
time: '2015-02-26 23:59:50'
System info:
host: 'SmithPC',
ip: '10.0.2.15',
os.name: 'Windows 7',
os.arch: 'x86',
os.version: '6.1',
java.version: '1.8.0_45'
Driver info:
driver.version: ChromeDriver
error at line: 7
I tried to run this piece of code through the Netbeans IDE, after adding the same selenium-standalone-server.jar package to empty java project. And it has completed without problems!
This is error-log of soapUI:
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.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'SmithPC', ip: '10.0.2.15', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_45'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:139)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:160)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:117)
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:422)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186)
at Script3.run(Script3.groovy:7)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:79)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:138)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:79)
at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:77)
at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:124)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:183)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:126)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:72)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:133)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:66)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572)
... 23 more
I also tried use FirefoxDriver() instead of ChromeDriver(), and got the same error.
I have encountered the same error, which said:
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.
but chromedriver.exe started fine. I can see it in task manager.
My environment is as following,
windows 7, ultimate, 64 bit system
selenium-server-standalone-2.47.1
chromedriver 2.19
google chrome: 45.0
After many tries suggested in google results, my final solution is to add 127.0.0.1 localhost to C:\Windows\System32\drivers\etc\hosts.
Hope to help you!
Download latest driver(chrome or IE) from seleniumhq.org, and use below code
System.setProperty("webdriver.chrome.driver","<YourPath>chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.yahoo.com");
This worked for me.
In selenium this error message:
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.
Could have a lot of causes. However looking at the stacktrace in this case is due to a NullPointerException:
Caused by: java.lang.NullPointerException
at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:79)
at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:77)
at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:124)
The problem is that you're using selenium inside SOAPUI. SOAPUI seems to set the default proxy to null (ProxySelector.setDefault(null)). So when selenium gets the default proxy an invoke a method on it, a NullPointerException is thrown.
The problem is that you executes your code inside SOAPUI so you can not get the default proxy before SOAPUI set it to null... then a possible workaround is in your Groovy testStep try to create a ProxySelector an set it as default before WebDriver is executed:
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import java.net.Proxy
import java.net.ProxySelector
def selectDirectProxy(URI uri) {
final List<Proxy> proxy = new ArrayList<Proxy>()
proxy.add(Proxy.NO_PROXY)
return proxy
}
// create a ProxySelector
ProxySelector proxySelector = [ select : { uri->selectDirectProxy(uri) } ] as ProxySelector
// set as default to avoid null pointer
ProxySelector.setDefault(proxySelector);
// now it's safe to invoke WebDriver...
System.setProperty('webdriver.chrome.driver', 'C:\\\\Windows\\system32\\chromedriver.exe')
log.info(System.getProperty('webdriver.chrome.driver')) //got 'C:\\Windows\system32\chromedriver.exe'
WebDriver driver = new ChromeDriver()
In this example I extend the ProxySelector abstract class in a groovy way, to set at least one direct proxy. If its necessary it's also possible to use the Proxy class to configure a no direct proxy and set it in the list, but with this code I'm trying to avoid the NPE due to SOAPUI ProxySelector.setDefault(null).
It already told you what happened:
//got 'C:**\\**Windows\system32\chromedriver.exe'
Try to define path using one of the next ways:
System.setProperty('webdriver.chrome.driver','C:\\Windows\\system32\\chromedriver.exe')
log.info(System.getProperty('webdriver.chrome.driver'))
OR
System.setProperty('webdriver.chrome.driver','C:/Windows/system32/chromedriver.exe')
log.info(System.getProperty('webdriver.chrome.driver'))
Also, I would not recommend you to store chromedriver.exe in system32 folder, especially if you don't have admin rights on the workstation. Use smt like C:/WebDrivers/hromedriver.exe
This could be a compatibility issue between the 'selenium', 'chrome browser version' and 'chrome driver' version that you are using.
It you are using Selenium 2.53 (like me), then using chrome driver 2.25 should work for you.
You can download it from here - https://chromedriver.storage.googleapis.com/index.html?path=2.25/
I encountered the same issue and upgrading to the latest chrome driver fixed my issue.
You can download the latest chrome driver from following URL.
http://chromedriver.storage.googleapis.com/index.html
It is best to use always the latest version. After downloading, set the path of chrome driver in System.setProperty("webdriver.chrome.driver","{Your path Chrome Driver}");
System.out.println("Creating Chrome Driver");
// Set Chrome Driver
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("{Your URL}");
This problem is totally related to the chrome browser version and chrome driver version.
Once you keep both browser and driver versions the same, your problem will get resolved.
To check the chrome version go to the following steps ->> Click on three vertical dots ->> Help ->> About Google Chrome Browser ->> see the chrome version.
Now check the chrome BROWSER version
in my case browser version is 90.0
Now download the same version of the chrome driver respective of the operating system
We will download the 90.0 version of driver, then set the browser path
System.setProperty("webdriver.chrome.driver", "D:\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("{Your URL}")
#JAVA #SELENIUM
If someone encountered a similar problem on Ubuntu, please check if you install Chromium web browser
Not enough to have only chrome browser.
More details

UnreachableBrowserException trying to launch in Selenium Webdriver using IEDriver

I have a set of automations that work fantastically in Firefox and Chrome, and I'd like to launch an instance of IEDriver as well.
I've set up IEDriver as per Selenium's Google Code wiki, with the correct path (if I change the path I get a different exception, so it's definitely correct). But for some reason it still can't launch, and just times out.
The code to launch it (the last line throws the exception):
File ieDriver = new File("C:/Users/whatever/path/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", ieDriver.getAbsolutePath());
WebDriver ie = new InternetExplorerDriver();
And the exception is:
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: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_21'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:201)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:184)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:174)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:143)
at uk.co.know.kiteTest.WebDriverManager.<init>(WebDriverManager.java:52)
at uk.co.know.kiteTest.RunAutomations.main(RunAutomations.java:13)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_21'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:165)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:62)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 7 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:38622/status] to be available after 20014 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:104)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:163)
... 9 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:79)
... 10 more
I was hitting this same error and then found this question. In my case, it turned out that I had the 64 bit version of the IEDriver.exe on my system, but I was on a 32 bit windows platform. So this error was indicating that the OS failed to execute the driver program. I tried to run the driver directly in a command prompt to see that infact the 32 bit OS was not recognizing the 64 bit driver exe as an executable program.
Getting the correct 32 bit IEDriver.exe solved my problem.
Selenium WebDriver with Chrome, issue:
(org.openqa.selenium.remote.UnreachableBrowserException) solution
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: '2.35.0', revision: '8df0c6b', time: '2013-08-12 15:43:19'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_40'
Driver info: driver.version: ChromeDriver
If you are getting above problem, go to the chromedriver.exe location and try to execute the exe. If you are able to execute the exe then below code will work. Otherwise it will be a permission issue to the chromedriver folder. Change the folder location or provide the permission to the folder and double click on chromedriver.exe.
Solution:
System.setProperty("webdriver.chrome.driver", "C:/Driver/chromedriver.exe");
System.out.println(System.getProperty("webdriver.chrome.driver"));
WebDriver driver3 = new ChromeDriver();
Go to hosts (C:\Windows\system32\drivers\etc)
and make sure that you have this line correctly:
127.0.0.1 localhost
Faced similar exception while trying to execute Selenium script over BrowserStack for mobile devices. And often found this exception being thrown.
Eventually realized being virtual machines involved, emulators were taking time to boot up and thus causing UnreachableBrowserException.
Wrote below code to handle this, by setting Number of times to retry(RetryCount) and made multiple attempts(retryAttempt) to check Remote WebDriver's availability.
while(retryAttempt<=retryCount){
try{
WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
return driver;
}
catch(UnreachableBrowserException e){
Thread.sleep(10000);
if(retryAttempt>retryCount){
logger.error("Remote Web Driver cannot be reached at this moment");
}
}
}
It seems to me you use improper driver initilization.
Try piece of code from my project:
File file = new File("C:/Selenium/iexploredriver.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
I had the same issue. This fixed it for me:
DesiredCapabilities capabilitiesIE = DesiredCapabilities.internetExplorer();
capabilitiesIE.setCapability(
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(capabilitiesIE);
If you are getting the this exception just download new chrome driver and provide the in your project. That's it. Worked for me :)

Categories

Resources