System.setProperty("webdriver.chrome.driver","D:/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://link");
driver.findElement(By.cssSelector("#username")).sendKeys("id");
driver.findElement(By.cssSelector("#password")).sendKeys("pass");
driver.findElement(By.cssSelector("#clientName")).sendKeys("name");
driver.findElement(By.cssSelector("#submitButton")).click();
System.out.println("Okay !");
I set property for Chrome Driver. When I run it gives an error. (Below) I searched a lot but didn't found any solution.
Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 10589
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: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:03.216Z'
System info: host: 'DESKTOP-9HVORCR', ip: '192.168.1.24', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:564)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:207)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
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 zaaa.main.main(main.java:11)
Caused by: java.lang.IllegalArgumentException: Unexpected char 0x131 at 23 in User-Agent value: selenium/3.12.0 (java wındows)
at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:338)
at okhttp3.Headers$Builder.add(Headers.java:288)
at okhttp3.Request$Builder.addHeader(Request.java:177)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:85)
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)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
... 6 more
I have tried these:
- 32/64 bit drivers.
- Run it as administrator.
- Creating a Try/Catch block.
- Other drivers. (Like Operadriver.exe) (Result: Same error)