Skip to content

Commit d8132d6

Browse files
committed
Attempt to reduce test crashes for chromedriver tests
1 parent 78fede9 commit d8132d6

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,38 @@
2828
import java.io.File;
2929
import java.io.IOException;
3030
import java.net.URL;
31+
import java.nio.file.Files;
32+
import java.nio.file.Path;
33+
import java.util.HashMap;
34+
import java.util.Map;
35+
import java.util.logging.Logger;
3136

3237
/**
3338
* Customized RemoteWebDriver that will communicate with a service that lives and dies with the
3439
* entire test suite. We do not use {@link org.openqa.selenium.chrome.ChromeDriver} since that starts and stops the service
3540
* with each instance (and that is too expensive for our purposes).
3641
*/
3742
public class TestChromeDriver extends RemoteWebDriver {
43+
private final static Logger LOG = Logger.getLogger(TestChromeDriver.class.getName());
44+
3845
private static ChromeDriverService service;
3946

4047
public TestChromeDriver() {
4148
super(chromeWithCustomCapabilities(null));
4249
}
4350

44-
public TestChromeDriver(Capabilities capabilities) {
51+
public TestChromeDriver(Capabilities capabilities) throws IOException {
4552
super(getServiceUrl(), chromeWithCustomCapabilities(capabilities));
4653
}
4754

48-
private static URL getServiceUrl() {
55+
private static URL getServiceUrl() throws IOException {
4956
if (service == null && !SauceDriver.shouldUseSauce()) {
50-
service = ChromeDriverService.createDefaultService();
57+
Path logFile = Files.createTempFile("chromedriver", ".log");
58+
service = new ChromeDriverService.Builder()
59+
.withVerbose(true)
60+
.withLogFile(logFile.toFile())
61+
.build();
62+
LOG.info("chromedriver will log to " + logFile);
5163
try {
5264
service.start();
5365
} catch (IOException e) {
@@ -68,7 +80,7 @@ public void run() {
6880
private static DesiredCapabilities chromeWithCustomCapabilities(
6981
Capabilities originalCapabilities) {
7082
ChromeOptions options = new ChromeOptions();
71-
options.addArguments("disable-extensions");
83+
options.addArguments("disable-extensions", "disable-infobars", "disable-breakpad");
7284
String chromePath = System.getProperty("webdriver.chrome.binary");
7385
if (chromePath != null) {
7486
options.setBinary(new File(chromePath));

0 commit comments

Comments
 (0)