-1

I am learning web crawling and trying to run a simple program to print title of the page. But I am getting an org.openqa.selenium.WebDriverException.

I have tried placing the chromedriver.exe file in C drive as well including options.addArguments("--no-sandbox") in program, but nothing worked. I have reinstalled chrome as well as placed it in C:\Users\HP\AppData\Local\Google\Chrome\Application\chrome.exe folder but this is also not working. First it was in C:\Program Files(x86)\Google\Chrome\Application Folder. On opening chrome from this location it is showing "The application was unable to start correctly(0xc0000022). Click ok to close the application".

package LearnCrawling;

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.support.ui.WebDriverWait;

public class ExampleofCrawling {

    public static void main(String[] args) {        

        System.setProperty("webdriver.chrome.driver", 
                    "D:\\chromedriver\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();

        driver.get("http://www.google.com");

        WebElement element = driver.findElement(By.name("q"));

        element.sendKeys("terminator\n");

        new WebDriverWait(driver, 10)
        .until(d -> d.getTitle().toLowerCase().startsWith("terminator"));

        System.out.println("Title: " + driver.getTitle());

        //driver.quit();

    }

}

I am getting following error in the eclipse window:

Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 1497
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: crashed
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location C:\Users\HP\AppData\Local\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 240 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'LAPTOP-17CRM6HV', ip: '192.168.43.48', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: driver.version: ChromeDriver
    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:214)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
    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 LearnCrawling.ExampleofCrawling.main(ExampleofCrawling.java:14)

I am running: Windows 10 (OS build 16299) Selenium 3.12.0 ChromeDriver 3.141.59 Chrome 73

Anyone have any suggestions as to what I might be doing wrong?

  • 2
    Possible duplicate of [ChromeWebDriver - unknown error: Chrome failed to start: crashed](https://stackoverflow.com/questions/25311593/chromewebdriver-unknown-error-chrome-failed-to-start-crashed) – esqew Apr 10 '19 at 19:15
  • 1
    Please refer https://stackoverflow.com/questions/50642308/org-openqa-selenium-webdriverexception-unknown-error-devtoolsactiveport-file-d – BlackPearl Apr 10 '19 at 19:15
  • Latest ChromeDriver is at version 74! Same as the browser. http://chromedriver.chromium.org/downloads Are you sure your version is 3? – SiKing Apr 11 '19 at 00:00

1 Answers1

0

You're missing ChromeOptions:

ChromeOptions options = new ChromeOptions();
driver = new ChromeDriver(options);
cs95
  • 379,657
  • 97
  • 704
  • 746
Bill Hileman
  • 2,798
  • 2
  • 17
  • 24