Attempt to reduce test crashes for chromedriver tests
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
* 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));
