selenium webDriver (Firefox) : connection refused [duplicate] - java

Recently I upgraded to Selenium 3.7.
Code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public static void main (String args[]){
System.setProperty("webdriver.gecko.driver",
"/usr/local/bin/geckodriver");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
driver.quit();
}
Included Library:
selenium-java-3.7.1/selenium-server-standalone-3.7.1.jar
selenium-java-3.7.1/libs/httpcore-4.4.6.jar
selenium-java-3.7.1/libs/httpclient-4.5.3.jar
selenium-java-3.7.1/libs/guava-23.0.jar
selenium-java-3.7.1/libs/gson-2.8.2.jar
selenium-java-3.7.1/libs/commons-logging-1.2.jar
selenium-java-3.7.1/libs/commons-exec-1.3.jar
selenium-java-3.7.1/libs/commons-codec-1.10.jar
selenium-java-3.7.1/libs/byte-buddy-1.7.5.jar
selenium-java-3.7.1/client-combined-3.7.1.jar
selenium-java-3.7.1/client-combined-3.7.1-sources.jar
System environment:
Firefox 56.0.2
Java 1.8
selenium-java-3.7.1
selenium-server-standalone-3.7.1
geckodriver - v0.19.1
Error trace log:
Usage:
/usr/local/bin/geckodriver [OPTIONS] /usr/local/bin/geckodriver:
Unknown option --port=8970 Exception in thread "main"
org.openqa.selenium.WebDriverException:
org.apache.http.conn.HttpHostConnectException: Connect to
localhost:8970 [localhost/0:0:0:0:0:0:0:1,
localhost/fe80:0:0:0:0:0:0:1%1] failed: Connection refused (Connection
refused) Build info: version: '3.7.1', revision: '8a0099a', time:
'2017-11-06T21:07:36.161Z' System info: host:
'Maggies-MacBook-Pro-2.local', ip: '192.168.1.6', os.name: 'Mac OS X',
os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: driver.version: FirefoxDriver
Any idea would be appreciated. Thank you.
Update after trying Debanjan suggestion:
Code:
public static void main (String args[]){
System.out.println("Debug 1");
System.setProperty("webdriver.gecko.driver",
"/Users/maggie/Documents/ToolsQA/Libs/geckodriver");
System.out.println("Debug 2");
WebDriver driver = new FirefoxDriver();
System.out.println("Debug 3");
driver.get("http://www.google.com");
driver.quit();
}
Include Library:
selenium-server-standalone-3.7.1.jar
System Environment:
Firefox 56.0.2
Java 1.8
selenium-java-3.7.1
selenium-server-standalone-3.7.1
geckodriver 0.19.1
Mac OS X', os.arch: 'x86_64', os.version: '10.12.6'
Error trace log:
Debug 1 Debug 2 Starting ChromeDriver 2.33.506106
(8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2) on port 2198 Only local
connections are allowed. Exception in thread "main"
org.openqa.selenium.WebDriverException: Timed out waiting for driver
server to start. Build info: version: '3.7.1', revision: '8a0099a',
time: '2017-11-06T21:07:36.161Z' System info: host:
'Maggies-MacBook-Pro-2.local', ip: '192.168.1.6', os.name: 'Mac OS X',
os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: driver.version: ChromeDriver at
org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192)
at
org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)
at
org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at
org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)
at AutomationFrameWork.FirstTestCase.main(FirstTestCase.java:13)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed
out waiting for [http://localhost:2198/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)
... 9 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:147)
at
org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
... 10 more

The error WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8970 can occur due to different reasons.
More over there is a discrepency in your Included Library list as selenium-server-standalone-3.7.1.jar is never a part of downloaded selenium-java-3.7.1.zip.
Try out the steps mentioned below:
From the Included Library list remove all the jars.
Download and Add only selenium-server-standalone-3.7.1.jar from this link or from this link
Ensure that /etc/hosts on your system contains the following entry :
1 127.0.0.1 localhost.localdomain localhost
Run CCleaner Tool to wipe away all the OS chores from your system.
You can opt for a System Reboot.
Execute your Test.

I tried with the same versions without any problem.
If the path to the geckodriver:
System.setProperty("webdriver.gecko.driver",
"/usr/local/bin/geckodriver");
is correct, make sure that the geckodriver is executable for the user that execute the code:
chmod +x geckodriver

After doing some research, I manage to resolve this problem.
The error is due to the 127.0.0.1 map to localhost.com in etc/hosts.
Edited:
127.0.0.1 localhost

I think you are missing the .exe extension. Your path should be like this
System.setProperty("webdriver.gecko.driver",
"/usr/local/bin/geckodriver.exe");

Related

How to resolve " org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/" with google driver?

I am facing above mentioned issue since 1 week. Earlier it was working smoothly. Even now sometimes it works fine but most of the time I am getting "Failed to connect to localhost/" error. :(
I have upgraded chrome driver to 2.37 now downgraded it again to 2.36 but no luck. :( Thanks.
Issue details:
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:4321
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'GURWUNknjk', ip: '10.202.126.154', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
Here is code for your reference:
Note : It works fine till login. Issue comes only when I try to search some element after login.
public static WebDriver driver;
public static void main(String[] args) throws InterruptedException, IOException {
System.setProperty("webdriver.chrome.driver", "d://chromedriver.exe");
driver = new ChromeDriver();
String url = "https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Faccounts.google.com%2Fb%2F0%2FAddMailService&flowName=GlifWebSignIn&flowEntry=AddSession";
driver.get(url);
driver.manage().window().maximize();
WebDriverWait wait = new WebDriverWait(driver, 20);
driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS) ;
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[type='Email']")));
if(driver.getCurrentUrl().contains("https://accounts.google.com/signin/v2/identifier?"))
{
driver.findElement(By.id("identifierId")).sendKeys(username);
driver.findElement(By.id("identifierNext")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.name("password")));
driver.findElement(By.name("password")).sendKeys(pwd);
driver.findElement(By.name("password")).sendKeys(Keys.ENTER);
}
else{
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[type='Email']")));
driver.findElement(By.name("Email")).sendKeys(UserName);
driver.findElement(By.id("next")).click(); wait.until(ExpectedConditions.presenceOfElementLocated(By.name("Passwd")));
driver.findElement(By.name("Passwd")).sendKeys(Pwd);
wait.until(ExpectedConditions.presenceOfElementLocated(By.name("signIn")));
driver.findElement(By.id("signIn")).click();
}
wait.until(ExpectedConditions
.visibilityOfElementLocated(By.id(element id)));
driver.findElement(By.id(element id))
.sendKeys(some value);
Thread.sleep(3000);
driver.findElement(By.id(element id)).click(); }
The error says it all :
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:4321
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'GURWUNknjk', ip: '10.202.126.154', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_131'
Driver info: driver.version: RemoteWebDriver
The error clearly shows that the ChromeDriver was not recognized as in :
Driver info: driver.version: RemoteWebDriver
Your main issue is the version compatibility between the binaries you are using as follows :
You are using chromedriver=2.37
Your chrome version is unknown to us.
Your Selenium Client version is 3.11.0.
Your JDK version is 1.8.0_131 which is pretty ancient.
So there is a clear mismatch between the JDK v8u131 , Selenium Client v3.11.0 , ChromeDriver version (v2.37).
Solution
Upgrade JDK to recent levels JDK 8u162.
Keep ChromeDriver at current ChromeDriver v2.37 level.
Keep Chrome version at Chrome v65.x levels. (as per ChromeDriver v2.37 release notes)
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.
Take a look at where you are instantiating the drive.
You wrote: System.setProperty("webdriver.chrome.driver", "d://chromedriver.exe");
I believe the issue is with the chrome drive path.
Try: "D:/chromedriver.exe");
There should be only one forward slash when defining the path.

Can't load google chrome driver in selenium java on linux

I've started using selenium over java in eclipse on linux (CentOS 6.6).
With Firefox everything works fine but with Chrome I'm getting:
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.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-504.el6.x86_64', java.version: '1.7.0_79'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at First.testGoogleSearch(First.java:24)
at First.main(First.java:18)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-504.el6.x86_64', java.version: '1.7.0_79'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:178)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 8 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:13244/status] to be available after 20001 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:175)
... 11 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:80)
What I've tried:
Changing the SetProperty to path to real path instead of symlink.
That's following additional stack-overflow posts on the issue which suggested the above.
Installing a higher version of Java (using 1.7, installed 1.8).
That's my code, help would be appreciated:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class First {
/**
* #param args
* #throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
testGoogleSearch();
}
public static void testGoogleSearch() throws InterruptedException {
//System.setProperty("webdriver.chrome.driver", "//home//shai//selenium//chromedriver");
System.setProperty("webdriver.chrome.driver", "//etc//alternatives//google-chrome");
WebDriver driver = new ChromeDriver();
driver.get("http://some url");
driver.quit();
}
}
There are various possibilities for this issue to occured.
Please check the chromedriver is whether 32 bit or 64 bit. It must match with your OS.
OR
It might be the because of folder permission. Please give execute permission to the folder where chromedriver is located.

Microsoft Edge: org.openqa.selenium.remote.SessionNotFoundException: null

Automating tests to edge browser through webDriver using java script.
System.setProperty("webdriver.edge.driver",
"C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe");
WebDriver driver = new EdgeDriver();
Already install MicrosoftWebDriver
And using selenium webdriver 2.48.2
OS: Microsoft Windows [Version 10.0.10565]
But got and Exception:
Exception in thread "main"
org.openqa.selenium.remote.SessionNotFoundException: null (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.14 seconds
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: 'DESKTOP-DUHBOA4', ip: '192.168.31.26', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.edge.EdgeDriver
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.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:152)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:141)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:98)
at test.edge.browser.UseEdgeBrowser.main(UseEdgeBrowser.java:18)
No clue for this. Do I still need to configure something?
There are 2 kinds of
1. Microsoft WebDriver: https://www.microsoft.com/en-us/download/details.aspx?id=48212
and
WebDriver for Windows Insiders: http://www.microsoft.com/en-us/download/details.aspx?id=48740
using 1 with this issue. using 2 works for me
It's some time ago, but here is the solution for everyone with the same error..
Your Windows build must be equal to the Microsoft WebDriver version(eg 14393). Just open start menu, type in "winver" and use the correct WebDriver (right hand side) on following page:
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

how to use selenium code in unix

I have a selenium code that uses chromedriver in windows. I have set the chromedriver using following:
ChromeDriverManager.getInstance().setup();
When i execute it in Windows, It works fine.
But when i create a jar for my code and execute it in unix using (java -cp xyz.jar classname). I get following error:
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 127 (Exit value: 127)
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.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'sample.home.com', ip: '10.1.30.207', os.name: 'Linux', os.arch: 'amd64', os.version: '3.14.35-28.38.amzn1.x86_64', java.version: '1.7.0_75'
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 com.snapdeal.hadoop.monitoring.hdfs_monitoring.HadoopM.main(HadoopM.java:68)
Can someone please confirm what changes should be done in my script so that it can be run on unix machine?

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