java.net.ConnectException: Failed to connect to localhost error with Selenium 3.11.0 with IEDriverServer and IE 11 on Windows 10 - selenium

I am very new to selenium and trying to set up selenium in my laptop to begin. I am unable to invoke IE from my simple code. The details are given below. Can you please help me to understand where the issue is
IE version: IE 11,
IE Driver: 64-bit,
OS: Windows 10 64 bit,
Selenium version: 3.11
Error:
Started InternetExplorerDriver server (64-bit)
3.9.0.0
Listening on port 29313
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29313
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:08.638Z'
System info: host: 'DESKTOP-B1D1PSJ', ip: '192.168.79.96', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:223)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:215)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:152)
at testing.Tryselenium.main(Tryselenium.java:31)
Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29313
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:240)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:101)
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)
... 6 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at okhttp3.internal.platform.Platform.connectSocket(Platform.java:125)
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:238)
Code:
mport java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
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.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Tryselenium {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver web;
/*System.setProperty("webdriver.chrome.driver","C:\\Users\\Divakar\\Documents\\General\\Learnings\\Selenium\\Others\\Set Up files\\Browser Drivers\\" + "chromedriver_x32.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("excludeSwitches",Arrays.asList("test-type"));
web = new ChromeDriver(chromeOptions);
web.manage().window().maximize();
web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);*/
System.setProperty("webdriver.ie.driver","E:\\General\\Learnings\\Selenium\\Others\\Set Up files\\Browser Drivers\\" + "IEDriverServer.exe");
DesiredCapabilities capab = DesiredCapabilities.internetExplorer();
capab.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
web = new InternetExplorerDriver();
web.manage().window().maximize();
web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);
/*FirefoxDriver web = new FirefoxDriver();
web = new FirefoxDriver();
web.manage().window().maximize();
web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);*/
web.get("http://www.icicibank.com/");
web.findElement(By.xpath("/html/body/div[1]/div[1]/div[1]/div/a[1]")).click();
web.findElement(By.xpath("/html/body/div[1]/div[1]/div[1]/div/div[3]/div/ul[1]/li[1]/a")).click();
web.findElement(By.xpath("/html/body/div[1]/div[2]/div[2]/div/div[1]/div/div[3]/a")).click();
web.findElement(By.name("AuthenticationFG.USER_PRINCIPAL")).sendKeys("507133118");
web.findElement(By.name("AuthenticationFG.ACCESS_CODE")).sendKeys("Soft2008");
web.findElement(By.name("Action.VALIDATE_CREDENTIALS")).click();
web.findElement(By.id("ContentLink1")).click();
WebElement accttable = web.findElement(By.xpath("/html/body/form/div/div[3]/div[1]/div[4]/div[2]/div/div/div[5]/div/div/div/div/div/div/div"));
List<WebElement> all_rows = accttable.findElements(By.tagName("tr"));
int j = 0;
for (int i = 0; i < all_rows.size(); i++) {
List<WebElement> rowAllCells = all_rows.get(i).findElements(By.tagName("td"));
if(rowAllCells.size()>1)
{
String acctno=rowAllCells.get(2).getText();
if(rowAllCells.get(2).getText().trim().equalsIgnoreCase("602605049934"))
{
web.findElement(By.id("AccountSummaryFG.SELECTED_INDEX")).click(); ///html/body/form/div/div[3]/div[1]/div[4]/div[2]/div/div/div[5]/div/div/div/div/div/div/div/table/tbody/tr[4]/td[1]/input
web.findElement(By.id("HREF_actNicNameOutput[" + j + "]")).click();
web.findElement(By.id("backBtn")).click();
web.findElement(By.id("VIEW_MINI_STATEMENT")).click();
web.findElement(By.id("HREF_Logout")).click();
web.close();
}
else j = j + 1;
}
}
}
}

The error says it all :
3.9.0.0
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29313
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:08.638Z'
System info: host: 'DESKTOP-B1D1PSJ', ip: '192.168.79.96', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_161'
Driver info: driver.version: InternetExplorerDriver
It is clear from your error stack trace that the new session is not getting initiated and the driver.version is also not getting recognized.
Your main issue is the version compatibility between the binaries you are using as follows :
You are using Selenium Client v3.11.0
You are using IEDriverServer v3.9.0.0
You are using InternetExplorer v11.0 (as per your question)
So there is a clear mismatch between the Selenium Client v3.11.0 , IEDriverServer v3.9.0.0.
Solution
Upgrade IEDriverServer to v3.11.1.
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 Browser base version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Browser.
Execute your #Test.
Additional Considerations
You are using the flag INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true which is against the best practice. Don't do it.

This answer is updated for Edge Browser. If you are using Edge Browser and facing the same issue. Then follow the steps:
Download the latest IEDriverServer from this location : https://selenium.dev/downloads/
Update your code as follows :
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
public class SL001_OpenWebpage_Edge
{
public static void main(String[] args)
{
System.setProperty("webdriver.ie.driver", "\\location\\IEDriverServer.exe");
WebDriver driver=new EdgeDriver();
driver.get("https://www.hul.co.in/");
driver.findElement(By.id("tcm:1255-50553-4")).click();
//driver.manage().window().maximize();
}
}

The issue in our case was not specific to Jenkins but the Chrome Driver crashing under the VMs where our automation tests run.
If you log into your VM machine and where your workspace have been copied into, and under the terminal run the same maven command you have on Jenkins you should be able to watch the tests run and this may be a way for you to identify and fix the issue.

I had this occur even with the same Driver and client versions.
Started InternetExplorerDriver server (32-bit)
3.141.59.0
...
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:XXXX
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'HOST_NAME', ip: 'XX.XXX.XX.XX', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_251'
Driver info: driver.version: RemoteWebDriver
I ended up finding a perfect match here
http://selenium-release.storage.googleapis.com/index.html
but the Security Settings in IE were different and not correct on a new computer. Making each zone have the same Enable Protected Mode box state (every one selected or deselected) in
Internet Options -> Security
Fixed it 100%. Was getting the driver to launch and navigate to a page, but the prior two steps fixed the errors.

Related

How to run selenium standalone server with Edge webdriver?

I'm trying to run Selenium tests against Edge, in the same way I successfully run with Chrome or Internet Explorer 11 but it fails.
What I do is starting the standalone selenium and it works fine:
java -Dwebdriver.edge.driver=C:\tmp\msedgedriver.exe -jar C:\tmp\selenium-server-standalone-3.141.59.jar -port 4445
But when I run the Selenium tests, it fails with the error below:
I've tried to add "-DbrowserName=edge" but it does not make any difference.
Is there something I've missed?
Build info: version: '3.8.1', revision: '6e95a6684b', time:
'2017-12-01T19:05:32.194Z' System info: host: 'MSEDGEWIN10', ip:
'10.0.2.15', os.name: 'Windows 10', os.arch: 'amd64', os.version:
'10.0', java.version: '1.8.0_201' Driver info: driver.version: unknown
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:89)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:171)
at org.openqa.selenium.remote.server.DefaultSession.(DefaultSession.java:88)
at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:76)
at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:72)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:63)
at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:37)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:112)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:191)
at org.openqa.selenium.remote.server.DriverServlet.lambda$handleRequest$0(DriverServlet.java:261)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748) 08:13:43.301 WARN - Exception: The best matching driver provider class
org.openqa.selenium.edge.EdgeDriver can't create a new driver instance
for Capabilities {browserName: edge}
Here's the java code I wrote to use Feature on Demand EdgeDriver. This has not been tested, so if you use it, let me know if it works:
String windir = System.getenv("windir");
boolean is64bit = false;
is64bit = (System.getenv("ProgramFiles(x86)") != null);
String edgeDriverPath = windir + "\\SysWOW64\\MicrosoftWebDriver.exe";
if (!is64bit)
{
edgeDriverPath = windir + "\\System32\\MicrosoftWebDriver.exe";
}
System.setProperty("webdriver.edge.driver", edgeDriverPath);
EdgeOptions edgeOptions = new EdgeOptions();
//edgeOptions.setPageLoadStrategy(stringPageLoadConstant);
try {
driver = new EdgeDriver(edgeOptions);
}
catch (Exception ex)
{
System.out.println ("Problem launching EdgeDriver: " + ex.toString());
}

Unable to open Google chrome using selenium webdriver [duplicate]

This question already has answers here:
WebDriverException: unknown error: cannot find Chrome binary error with Selenium in Python for older versions of Google Chrome
(8 answers)
Closed 3 years ago.
I am trying open a google chrome using selenium webdriver but I'm getting the below error :
Starting ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb) on port 18885
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 6.1.7600 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 110 milliseconds
Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:41'
System info: host: 'ADMIN-PC', ip: '192.168.244.1', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_191'
Driver info: driver.version: ChromeDriver
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:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$errorHandler$0(JsonWireProtocolResponse.java:54)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
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:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
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 demo.main(demo.java:9)
I have tried everything but no use.
Below is my program :
public class demo {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\Admin\\Desktop\\Internal job application\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://google.com");
}
}
Need assistance on what action needs to taken
You are getting that error because your chrome browser is not installed in the default installation directory or selenium not able to find executable chrome browser file.
To solve this problem, you need to tell the program where your chrome browser executable is present and for that you can use ChromeOptions class like below :
public class demo {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\Admin\\Desktop\\Internal job application\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/chrome/binary"); // Provide absolute executable chrome browser path with name and extension here
WebDriver driver = new ChromeDriver(options);
driver.get("http://google.com");
}
}
I hope it helps...
Install Chrome browser in destination by default.
In this line:
System.setProperty("webdriver.chrome.driver", "destination to file"
destination to file is not destination to installed Chrome browser, but destination to downloaded here chrome driver.

data:, shown in the chrome url bar when I execute the following Selenium ChromeWebdrive Script

data:, shown in the chrome url bar when I execute the following Selenium ChromeWebdrive Script. Is the because other instance of chrome browser are working?
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ChromWebdriverWindows {
public static void main(String[] args) {
//String url = "https://www.google.co.in/";
System.getProperty("webdriver.chrome.driver", "C:\\Automation\\chromedriver_win32\\chromedriver.exe");
WebDriver drive;
drive = new ChromeDriver();
drive.get("https://www.flock.co");
}
}
Getting this error in console:
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 7264
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800'
System info: host: 'MDVLFARZANS', ip: '192.168.0.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
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:178)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:167)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
at ChromWebdriverWindows.main(ChromWebdriverWindows.java:10)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:139)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:155)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:284)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:261)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:165)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:167)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:272)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
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:142)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:88)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:296)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:113)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 8 more
Your code looks fine just replace .getProperty() with .setProperty():
System.getProperty("webdriver.chrome.driver",
"C:\\Automation\\chromedriver_win32\\chromedriver.exe");
with
System.setProperty("webdriver.chrome.driver",
"C:\\Automation\\chromedriver_win32\\chromedriver.exe");

Permission denied to access property "H"

I have written the below code to capture the entire screen shot of a webpage using java script.
I'm Using:
Firefox Version: 49.0.1
Chrome Version: 54.0.2840.59 m
Selenium Version: 3.0.0
OS: Win10 64 bit
Java: 1.8
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ScreenCapture {
public static void main(String[] args) throws IOException {
System.setProperty("webdriver.gecko.driver","C:\\Eclipse\\Drivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.flipkart.com/");
driver.manage().window().maximize();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
File capture = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(capture, new File("C:\\Users\\Vishvambruth JT\\Desktop\\FlipKart.jpg"));
}
}
The webpage will scroll down but the code stops abruptly with the below error. Could you please help.
1476679740598 geckodriver INFO Listening on 127.0.0.1:38310
Oct 16, 2016 11:49:00 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
1476679741083 mozprofile::profile INFO Using profile path C:\Users\VISHVA~1\AppData\Local\Temp\rust_mozprofile.h4P3qq7Ekmrz
1476679741083 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1476679741083 geckodriver::marionette INFO Connecting to Marionette on localhost:50064
1476679742059 Marionette INFO Listening on port 50064
1476679743366 Marionette INFO startBrowser 6f833edf-0ff4-4f1f-869c-1de62f8626a9
Oct 16, 2016 11:49:03 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.WebDriverException: Permission denied to access property "H"
Build info: version: 'unknown', revision: '350cf60', time: '2016-10-13 10:43:56 -0700'
System info: host: 'LAPTOP-JUUNTJIC', ip: '10.0.0.112', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20160922113459, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=9960, browserVersion=49.0.1, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}]
Session ID: 6f833edf-0ff4-4f1f-869c-1de62f8626a9
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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:537)
at ScreenCapture.main(ScreenCapture.java:19)
I got the same error for Selenium Web Driver 3.0.1.
The problem was gone when switching to version 2.53.1.
I too got this issue and after some research, I can say it is not problem of Selenium. It is problem with gecko driver. You can run it with chrome and it will work fine.
Just update to Firefox Night and it will work.
The Firefox Night can be found at https://www.mozilla.org/en-US/firefox/channel/desktop/ (the one labeled Beta).
It's better to use an up-to-date webdriver version with an up-to-date Firefox Night version (all the code and efforts of development and code issues are focused on that synchronization, and of course it makes sense in order to cover newer final users scenarios better).

Getting an exception while opening the Chrome Browser from Selenium 2 script

Program:
Below given is the code snipped i'm tring to run. However it is failing to open the Chrome Browser. Browser just opens and closes in fraction of a secod with the below given exception in the console.
public static void main(String[] args) {
WebDriver driver = null;
//Map<String, Object> testDataMap = null;
try{
//testDataMap = LoadConfiguration.getTestDataMap();
System.setProperty("webdriver.chrome.driver","D:\\chromedriver_win32\\chromedriver.exe");
Thread.sleep(5000l);
driver = new ChromeDriver();
//driver = LoadConfiguration.getDriver();
System.out.println("Opening the Browser");
driver.get("http://localhsot:5080/myWebSite/8450191#");
Thread.sleep(2000l);
System.out.println("Open the Browser");
System.out.println("");
System.out.println("Title" +driver.getTitle());
}catch (Exception ie){
ie.printStackTrace();
}finally{
System.out.println("Quitting the Browser");
if(null != driver){
driver.close();
driver.quit();
}
}
}
Exception:
Starting ChromeDriver (v2.9.248315) on port 13737
org.openqa.selenium.WebDriverException: unknown error: version info not a dictionary
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.99 seconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: '01hw535163', ip: '10.72.15.53', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_17'
Driver info: org.openqa.selenium.chrome.ChromeDriver
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:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
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.<init>(RemoteWebDriver.java:111)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:115)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
at com.seic.scripts.TestScript.main(TestScript.java:24)
Quitting the Browser
OS: Windows 7, 64 bit
Browser Version: 21.0.1171.0
chromedriver=2.9.248315
Looks like old chrome version is causing this issue. Current chrome version is > 32. Update chrome and give a try.
Source