@@ -28,11 +28,13 @@ final class ChromeManager implements BrowserManagerInterface
28
28
29
29
private $ process ;
30
30
private $ arguments ;
31
+ private $ options ;
31
32
32
- public function __construct (?string $ chromeDriverBinary = null , ?array $ arguments = null )
33
+ public function __construct (?string $ chromeDriverBinary = null , ?array $ arguments = null , array $ options = [] )
33
34
{
34
35
$ this ->process = new Process ([$ chromeDriverBinary ?? $ this ->findChromeDriverBinary ()], null , null , null , null );
35
36
$ this ->arguments = $ arguments ?? $ this ->getDefaultArguments ();
37
+ $ this ->options = \array_merge ($ this ->getDefaultOptions (), $ options );
36
38
}
37
39
38
40
/**
@@ -42,10 +44,11 @@ public function __construct(?string $chromeDriverBinary = null, ?array $argument
42
44
*/
43
45
public function start (): WebDriver
44
46
{
47
+ $ url = $ this ->options ['scheme ' ].':// ' .$ this ->options ['host ' ].': ' .$ this ->options ['port ' ];
45
48
if (!$ this ->process ->isRunning ()) {
46
- $ this ->checkPortAvailable (' 127.0.0.1 ' , 9515 );
49
+ $ this ->checkPortAvailable ($ this -> options [ ' host ' ], $ this -> options [ ' port ' ] );
47
50
$ this ->process ->start ();
48
- $ this ->waitUntilReady ($ this ->process , ' http://127.0.0.1:9515/status ' );
51
+ $ this ->waitUntilReady ($ this ->process , $ url . $ this -> options [ ' path ' ] );
49
52
}
50
53
51
54
$ capabilities = DesiredCapabilities::chrome ();
@@ -55,7 +58,7 @@ public function start(): WebDriver
55
58
$ capabilities ->setCapability (ChromeOptions::CAPABILITY , $ chromeOptions );
56
59
}
57
60
58
- return RemoteWebDriver::create (' http://localhost:9515 ' , $ capabilities );
61
+ return RemoteWebDriver::create ($ url , $ capabilities );
59
62
}
60
63
61
64
public function quit (): void
@@ -89,4 +92,14 @@ private function getDefaultArguments(): array
89
92
90
93
return $ args ;
91
94
}
95
+
96
+ private function getDefaultOptions (): array
97
+ {
98
+ return [
99
+ 'scheme ' => 'http ' ,
100
+ 'host ' => '127.0.0.1 ' ,
101
+ 'port ' => 9515 ,
102
+ 'path ' => '/status ' ,
103
+ ];
104
+ }
92
105
}
0 commit comments