markshead / bdd-demo

0 stars 0 forks source link

chrome driver not launching chrome in windows 10 #1

Open pcooke2002 opened 5 years ago

pcooke2002 commented 5 years ago

My system is windows 10, open jdk-11. I have chrome installed on the system. with basic "mvn clean install -X -e " I get

defined in file [C:\Users\l1pxc04\Downloads\bdd-demo-master\bdd-demo-master\target\test-classes\net\xeric\demos\pages\DemoPage.class]: Unsatisfied Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoPage' dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getWebDriver' defined in class path resource [net/xeric/demos/TestConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'getWebDriver' threw exception; nested exception is org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary

When I add chrome to the from of the search path I get

 Error creating bean with name 'demoPage' defined in file [C:\eclipse-workspace\atdd\target\test-classes\frb\sf\agile\pages\DemoPage.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getWebDriver' defined in class path resource [frb/sf/agile/TestConfig.class]: Bean i     instantiation via factory method failed; nested exception is          org.springframework.beans.BeanInstantiationException: Failed to instantiate   [org.openqa.selenium.WebDriver]: Factory method 'getWebDriver' threw exception; nested   exception is org.openqa.selenium.WebDriverException: unknown error: Chrome failed to    start: crashed 
    (unknown error: DevToolsActivePort file doesn't exist)

Searching google indicate that TestConfig.java should have something like @Bean(destroyMethod = "quit") @Lazy @Scope("singleton") public WebDriver getWebDriver() { String driverPath = LINUX_CHROME_DRIVER; String osType = System.getProperty("os.name"); ChromeOptions options = null;

    driverPath = WINDOWS_CHROME_DRIVER;
    options = new ChromeOptions();
    options.addArguments("--start-maximized"); // open Browser in maximized mode
    options.addArguments("--disable-infobars"); // disabling infobars
    options.addArguments("--disable-extensions"); // disabling extensions
    options.addArguments("--disable-gpu"); // applicable to windows os only
    options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
    options.addArguments("--no-sandbox"); // Bypass OS security model
    options.addArguments("--illegal-access=info");
    options.addArguments("--headless");

    options.setBinary("C:\\Users\\l1pxc04\\Desktop\\chrome.exe - Shortcut.lnk");

    System.setProperty("webdriver.chrome.driver", driverPath);
    System.out.println(">>>>>driverpath=" + driverPath);
    System.out.println("!!!!" + options);
    return new ChromeDriver(options);
}

But I still cannot get it to lauch chrome on windows 10 using open jdk 11.

markshead commented 5 years ago

Double check and make sure that WINDOWS_CHROME_DRIVER is pointing to something that is actually there on your system. You might need to update it to a newer version of chrome driver as well....just in case there is an incompatibility between the version of Chrome you are using and the version of chromedriver in the project. You also might try not doing it headless just to get it to work.

Does Firefox work?