From d8132d657099fe3163b0663cc45a9454ccdaa79f Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Wed, 15 Mar 2017 17:56:46 +0000 Subject: [PATCH] Attempt to reduce test crashes for chromedriver tests --- .../testing/drivers/TestChromeDriver.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java b/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java index aa3129ca04bbc..1df849c39c446 100644 --- a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java +++ b/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java @@ -28,6 +28,11 @@ import java.io.File; import java.io.IOException; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; /** * Customized RemoteWebDriver that will communicate with a service that lives and dies with the @@ -35,19 +40,26 @@ * with each instance (and that is too expensive for our purposes). */ public class TestChromeDriver extends RemoteWebDriver { + private final static Logger LOG = Logger.getLogger(TestChromeDriver.class.getName()); + private static ChromeDriverService service; public TestChromeDriver() { super(chromeWithCustomCapabilities(null)); } - public TestChromeDriver(Capabilities capabilities) { + public TestChromeDriver(Capabilities capabilities) throws IOException { super(getServiceUrl(), chromeWithCustomCapabilities(capabilities)); } - private static URL getServiceUrl() { + private static URL getServiceUrl() throws IOException { if (service == null && !SauceDriver.shouldUseSauce()) { - service = ChromeDriverService.createDefaultService(); + Path logFile = Files.createTempFile("chromedriver", ".log"); + service = new ChromeDriverService.Builder() + .withVerbose(true) + .withLogFile(logFile.toFile()) + .build(); + LOG.info("chromedriver will log to " + logFile); try { service.start(); } catch (IOException e) { @@ -68,7 +80,7 @@ public void run() { private static DesiredCapabilities chromeWithCustomCapabilities( Capabilities originalCapabilities) { ChromeOptions options = new ChromeOptions(); - options.addArguments("disable-extensions"); + options.addArguments("disable-extensions", "disable-infobars", "disable-breakpad"); String chromePath = System.getProperty("webdriver.chrome.binary"); if (chromePath != null) { options.setBinary(new File(chromePath));