-
Notifications
You must be signed in to change notification settings - Fork 24
seleniumQuery and Chrome Driver
If you are having problems setting up ChromeDriver, make sure you check ChromeDriver's official page.
To use Chrome as driver in seleniumQuery, see below.
$.driver()
.useChrome() // sets Chrome as the driver
.headless() // configures chrome to be headless
.autoDriverDownload() // automatically downloads and configures chromedriver.exe
.autoQuitDriver(); // automatically quits the driver when the JVM shuts down
// now use normally
$.url("http://www.google.com/?hl=en");
$(":text[name='q']").val("seleniumQuery"); // the keys are actually typed!
$(":button[value='Google Search']").waitUntil().isVisible().then().click();
To get the latest version of seleniumQuery, add to your pom.xml
:
<dependency>
<groupId>io.github.seleniumquery</groupId>
<artifactId>seleniumquery</artifactId>
<version>0.18.0</version>
</dependency>
If you have manually downloaded chromedriver.exe
(chromedriver
, if linux) is at your PATH or classpath, do:
// will look for chromedriver.exe at the classpath; at
// the "webdriver.chrome.driver" system property or at the system PATH
$.driver().useChrome();
// now use normally
$.url("http://www.google.com/?hl=en");
$(":text[name='q']").val("seleniumQuery"); // the keys are actually typed!
$(":button[value='Google Search']").waitUntil().isVisible().then().click();
If chromedriver.exe
is not at your PATH or classpath, use:
// will look for the executable server in the given path. Path can be relative.
String chromeDriverPath = "C:\\myFiles\\chromedriver_evenRenamed.exe";
$.driver().useChrome().withPathToChromeDriverExe(chromeDriverPath);
// now use normally
$.url("http://www.google.com/?hl=en");
$(":text[name='q']").val("seleniumQuery"); // the keys are actually typed!
$(":button[value='Google Search']").waitUntil().isVisible().then().click();
chromedriver.exe
's latest version can be downloaded from ChromeDriver download page.
If you get UnreachableBrowserException
caused by org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
or similar:
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 37566
Only local connections are allowed.
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: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'my-pc', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: SeleniumQueryDriver
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:138)
at io.github.seleniumquery.browser.driver.builders.ChromeDriverBuilder.build(ChromeDriverBuilder.java:97)
at io.github.seleniumquery.browser.driver.SeleniumQueryDriver.get(SeleniumQueryDriver.java:75)
at io.github.seleniumquery.browser.BrowserFunctions.url(BrowserFunctions.java:77)
at hello.SeleniumQueryExample.main(SeleniumQueryExample.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:143)
Caused by: org.openqa.selenium.WebDriverException: java.net.SocketException: Connection reset
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'my-pc', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: SeleniumQueryDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 14 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
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:144)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 15 more
Fix:
Make sure you have the latest dependency on:
And you are using the latest Chrome Driver executable (chromedriver.exe).
Or let seleniumQuery automatically download and configure the executable for you:
$.driver()
.useChrome() // sets Chrome as the driver
.headless() // configures chrome to be headless
.autoDriverDownload() // automatically downloads and configures chromedriver.exe
.autoQuitDriver(); // automatically quits the driver when the JVM shuts down
// now use normally
$.url("http://www.google.com/?hl=en");
$(":text[name='q']").val("seleniumQuery"); // the keys are actually typed!
$(":button[value='Google Search']").waitUntil().isVisible().then().click();
To get the latest version of seleniumQuery, add to your pom.xml
:
<dependency>
<groupId>io.github.seleniumquery</groupId>
<artifactId>seleniumquery</artifactId>
<version>0.18.0</version>
</dependency>