28
28
import java .io .File ;
29
29
import java .io .IOException ;
30
30
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 ;
31
36
32
37
/**
33
38
* Customized RemoteWebDriver that will communicate with a service that lives and dies with the
34
39
* entire test suite. We do not use {@link org.openqa.selenium.chrome.ChromeDriver} since that starts and stops the service
35
40
* with each instance (and that is too expensive for our purposes).
36
41
*/
37
42
public class TestChromeDriver extends RemoteWebDriver {
43
+ private final static Logger LOG = Logger .getLogger (TestChromeDriver .class .getName ());
44
+
38
45
private static ChromeDriverService service ;
39
46
40
47
public TestChromeDriver () {
41
48
super (chromeWithCustomCapabilities (null ));
42
49
}
43
50
44
- public TestChromeDriver (Capabilities capabilities ) {
51
+ public TestChromeDriver (Capabilities capabilities ) throws IOException {
45
52
super (getServiceUrl (), chromeWithCustomCapabilities (capabilities ));
46
53
}
47
54
48
- private static URL getServiceUrl () {
55
+ private static URL getServiceUrl () throws IOException {
49
56
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 );
51
63
try {
52
64
service .start ();
53
65
} catch (IOException e ) {
@@ -68,7 +80,7 @@ public void run() {
68
80
private static DesiredCapabilities chromeWithCustomCapabilities (
69
81
Capabilities originalCapabilities ) {
70
82
ChromeOptions options = new ChromeOptions ();
71
- options .addArguments ("disable-extensions" );
83
+ options .addArguments ("disable-extensions" , "disable-infobars" , "disable-breakpad" );
72
84
String chromePath = System .getProperty ("webdriver.chrome.binary" );
73
85
if (chromePath != null ) {
74
86
options .setBinary (new File (chromePath ));
0 commit comments