Ramanujan R Ramanujan R - 1 month ago 20
Java Question

Selenium Webdriver Communication Error

I'm doing a java project which uses selenium web driver to automatically do tasks in a website, but getting errors.

Set

System.setProperty("webdriver.chrome.driver","path to chrome driver");


Have this method

public boolean openBrowserAndLoadUrl(String url) {
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions","--start-maximized");
WebDriver driver = new ChromeDriver(options);
if(driver==null)
return false;
driver.get("https://www.google.co.in");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
return true;
}


pom.xml

<org.seleniumhq-version>2.53.1</org.seleniumhq-version>

<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${org.seleniumhq-version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.23</version>
</dependency>


The 'driver' variable is initialized and Google Chrome is opened. Eclipse debugging shows exception occurs here
driver.get("https://www.google.co.in");


Got two types of error in two times!. Both stacktrace are shown below.


org.openqa.selenium.remote.UnreachableBrowserException: Error
communicating with the remote browser. It may have died.

Build info:
version: '2.53.1', revision:
'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30
19:26:09' System info: host: 'fms-dev', ip: '192.168.1.56', os.name:
'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version:
'1.8.0_101'

Driver info: driver.version: RemoteWebDriver Capabilities
[{applicationCacheEnabled=false, rotatable=false,
chrome={userDataDir=C:\Users\fms\AppData\Local\Temp\scoped_dir3000_27723},
takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true,
version=54.0.2840.71, platform=WIN8_1, browserConnectionEnabled=false,
nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true,
webStorageEnabled=true, browserName=chrome, takesScreenshot=true,
javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID:
05d03919d730cf29cb2267aba8f0de45 at

org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at
org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:316)


Later i got this error


org.openqa.selenium.WebDriverException: unknown error:
Runtime.executionContextCreated has invalid 'context':
{"auxData":{"frameId":"4492.1","isDefault":true},"id":1,"name":"","origin":"://"}

(Session info: chrome=54.0.2840.71) (Driver info:
chromedriver=2.9.248315,platform=Windows NT 6.3 x86_64) (WARNING: The
server did not provide any stacktrace information)

Command duration or
timeout: 39 milliseconds Build info: version: '2.53.1', revision:
'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30
19:26:09' System info: host: 'dev-pc', ip: '192.168.1.56', os.name:
'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version:
'1.8.0_101' Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false,
chrome={userDataDir=C:\Users\dev\AppData\Local\Temp\scoped_dir960_31279},
takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true,
version=54.0.2840.71, platform=WIN8_1, browserConnectionEnabled=false,
nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true,
webStorageEnabled=true, browserName=chrome, takesScreenshot=true,
javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID:
a1f32c762f3525f55845afd4ab824af5 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:206)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at
org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:316)


On further research, i understand many had this issue, but I didn't get any solution except incompatible version issue. But i am using downloaded chromedriver.exe

Also, earlier all the selenium steps had succeeded with this chrome driver and same selenium version.. Don't know why this happened now! Please help.

Answer

Google Chrome installed in your windows system may have been updated automatically.
You can download the latest driver from the chrome driver website.