I am automating android using Appium against real devices. I observed that if my script wait for some time, e.g. 10 seconds, then I call driver.currentActivity(). This will cause following Exception:
org.openqa.selenium.WebDriverException: java.net.SocketException: Software caused connection abort: recv failed
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_192'
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:233)
....
Caused by: java.net.SocketException: Software caused connection abort: recv failed
I have tried to google it, but seems no open issue for this. Can anyone suggest what could be wrong? Here is automation script:
public static void main(String[] args) {
try {
DesiredCapabilities oMobileCapability = new DesiredCapabilities();
oMobileCapability.setCapability("deviceName", "****");
oMobileCapability.setCapability("platformName", "Android");
oMobileCapability.setCapability("platform", "Android");
oMobileCapability.setCapability("appPackage", "****");
oMobileCapability.setCapability("appActivity", "****");
oMobileCapability.setCapability("language", "en");
oMobileCapability.setCapability("locale", "US");
oMobileCapability.setCapability("newCommandTimeout", 300);
AndroidDriver<AndroidElement> oDriver;
oDriver = new AndroidDriver<AndroidElement>(new URL ("http://localhost:4723/wd/hub"), oMobileCapability);
Thread.sleep(10000);
System.out.println("Wait Complete!");
System.out.println(oDriver.currentActivity());
oDriver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
I can see "Wait Complete!", then Exception happens. I am connecting to local Appium node directly.
Appium: v1.9.1
Java: 8
java-client: 6.0.0
Feb 2 UPDATE
This issue was found during trouble shooting this issue:
Appium server automatically quit session while waiting
Related
I am trying to run my automation on azure devops environment and phantomjs driver is getting timedout with below error message, can someone please help in resolving this problem
2019-10-30T16:13:27.8547904Z verifyXXXXActionPanel(com.xx.xxx.xxxxxxxx.tests.Dashboard.Testxxxxxxx) Time elapsed: 20.01 sec <<< FAILURE!
2019-10-30T16:13:27.8547948Z org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
2019-10-30T16:13:27.8606707Z Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
2019-10-30T16:13:27.8607855Z System info: host: '495c34b84843', ip: '172.17.42.5', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1055-azure', java.version: '1.8.0_191'
2019-10-30T16:13:27.8607969Z Driver info: driver.version: PhantomJSDriver
2019-10-30T16:13:27.8608049Z at java.util.concurrent.FutureTask.get(FutureTask.java:205)
2019-10-30T16:13:27.8608497Z at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:154)
2019-10-30T16:13:27.8608567Z at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)
2019-10-30T16:13:27.8608609Z at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
2019-10-30T16:13:27.8608650Z at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:168)
2019-10-30T16:13:27.8608709Z at org.openqa.selenium.phantomjs.PhantomJSCommandExecutor.execute(PhantomJSCommandExecutor.java:78)
2019-10-30T16:13:27.8608751Z at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
2019-10-30T16:13:27.8608792Z at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
2019-10-30T16:13:27.8608850Z at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
2019-10-30T16:13:27.8608901Z at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:141)
2019-10-30T16:13:27.8608947Z at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:115)
2019-10-30T16:13:27.8608987Z at org.openqa.selenium.phantomjs.PhantomJSDriver.(PhantomJSDriver.java:104)
2019-10-30T16:13:27.8609047Z at com.wm.bua.corpcreditcard.driverFactory.BrowserFactory.getWebDriver(BrowserFactory.java:195)
2019-10-30T16:13:27.8609088Z at com.wm.bua.corpcreditcard.driverFactory.BrowserFactory.getBrowser(BrowserFactory.java:61)
2019-10-30T16:13:27.8609129Z at com.wm.bua.corpcreditcard.tests.Dashboard.TestCorpCardManager.verifyManagerActionPanel(TestCorpCardManager.java:147)
below are the DesiredCapabilities which I tried using when trying to launch phantomjs driver
ClassLoader classLoader = new BrowserFactory().getClass().getClassLoader();
File phantomJS = new File(classLoader.getResource("drivers/phantomjs").getFile());
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,phantomJS.getAbsolutePath());
String[] cli_args = new String[]{ "--ssl-protocol=tlsv1", "--ignore-ssl-errors=true", "--web-security=false" };
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, "--webdriver-loglevel=ERROR");
capabilities.setCapability("takesScreenshot", false);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cli_args);
capabilities.setCapability("locationContextEnabled", true);
capabilities.setCapability("applicationCacheEnabled", true);
capabilities.setCapability("browserConnectionEnabled", true);
capabilities.setCapability("localToRemoteUrlAccessEnabled", true);
WebDriver driver = new PhantomJSDriver(capabilities);
Phantomjs usage is deprecated. You are using selenium3
The above error occurs may be selenium version may be incompatible to phantomjs driver try a compatible version maybe it works
But I recommend you to go with Chrome headless
I think the existing stack post will help you
https://stackoverflow.com/a/36769777/12167800
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");
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.
I am using Selenium InternetExplorerDriver to perform some basic actions. In this case, all I am trying to do is bring up IE and navigate to a webpage. So far, I am able to bring up IE, but all I see is: "This is the initial start page for the WebDriver server."
I've spent a lot of time trying to research this problem and have tried a few things, none of which worked. Two of the many things I've tried are:
Setting Protected mode on for all
Ignoring security settings completely
At this point, I am stuck and have no idea how to proceed with IE.
My code:
public void setUp() throws IOException {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
prop.load(inputStream);
/** Set path for Log4j */
String pathtolog4j = prop.getProperty("PathToLog4j");
PropertyConfigurator.configure(pathtolog4j);
/** Bring up IEDriver & load application */
String pathtoIEdriver = prop.getProperty("PathToIEDriver");
File file = new File(pathtoIEdriver);
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver();
logger.info("Get URL");
String url = prop.getProperty("appURL");
driver.navigate().to(url);
}
Stacktrace:
Started InternetExplorerDriver server (64-bit) 2.35.3.0
Listening on port 4297
org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Could not get document from window handle (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.80 seconds
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.6.0_43'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:151)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
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:147)
at TestScripts.Drivers.InternetExplorer.IEDriverSetup.setUp(IEDriverSetup.java:64)
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 :)