2
public class Dem {
    public static void main(String[] args) throws InterruptedException {
    WebDriver driver;
    String url = "https://www.google.com";
    System.setProperty("webdriver.chrome.driver","C:\\Users\\Jim\\Downloads\\chromedriver_win32\\chromedriver.exe");
    driver = new ChromeDriver();
    driver.get(url);
    driver.close();
    }
}

Selenium webdriver and Chrome driver are the latest versions

Selenium webdriver :3.14.0

chromedriver: 2.42

java:1.8.0_181

And this is the error after running the code. Google chrome doesn't launch at all.

SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: -1073741792 (Exit value: -1073741792) Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:193) at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:179) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:130) 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 news.Dem.main(Dem.java:17) Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:32986/status] to be available after 20002 ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:188) ... 9 more

Ashish Kamble
  • 2,555
  • 3
  • 21
  • 29
Jim isaac
  • 751
  • 1
  • 7
  • 13

2 Answers2

7

Debugging Steps

It may be either of the two below issue.

1. Chrome Driver not started for some reason:

Run the chrome driver in terminal maually

C:\Users\Jim> C:\Users\Jim\Downloads\chromedriver_win32\chromedriver.exe

Now we have to get the following message denoting server started sucessfully. enter image description here

If you are not getting above message and your server is not started, then check what is error you are getting and respond accorsingly? May downloaded corrupted binary, the download it again.

2. Unable to access the chrome driver with hostname as localhost

If you able to start chromedriver sucessfully as in above steps, now try to access the below url with respective port. http://localhost:{port}/status

For e.g., in above message, the server started on port 9515. Access the url in browser, http://localhost:9515/status

enter image description here

You should get above message indicating server is accessible with hostname as localhost

If your are not able access, then open C:\Windows\System32\drivers\etc\hosts in editor with administrator privilege and check localhost DNS is mapped to 127.0.0.1

enter image description here

Navarasu
  • 8,209
  • 2
  • 21
  • 32
  • When i try to run it from the terminal it pops an error message saying chromedriver.exe bad image. I believe there is some prob with the installation of chrome – Jim isaac Oct 17 '18 at 06:08
  • 1
    Yes. Not problem with chrome browser. The downloaded chomedriver.exe should be bad image. Download the binary again. – Navarasu Oct 17 '18 at 08:35
  • 1
    yes there was a bad dll. I ran a scan and fixed it. Thank you – Jim isaac Oct 17 '18 at 10:07
0
public class Demo {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver","\PATH OF THE DRIVER");
        WebDriver driver = new Chrome driver();
        String url = "https://www.google.com";
        driver.get(url);
        Thread.sleep(2000);
        driver.close();
    }
}
scopchanov
  • 7,966
  • 10
  • 40
  • 68