Skip to content

Commit 1d4ac8c

Browse files
Pierstovaldunglas
authored andcommitted
Allow using an env var to determine chrome driver binary (#49)
* Allow using an env var to determine chrome driver binary * Added small documentation to use the PANTHERE_CHROME_DRIVER_BINARY env var
1 parent f8f6d4c commit 1d4ac8c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ The following environment variables can be set to change some Panthère behavior
145145
* `PANTHERE_NO_HEADLESS`: to disable browsers's headless mode (will display the testing window, useful to debug)
146146
* `PANTHERE_NO_SANDBOX`: to disable [Chrome's sandboxing](https://chromium.googlesource.com/chromium/src/+/b4730a0c2773d8f6728946013eb812c6d3975bec/docs/design/sandbox.md) (unsafe, but allows to use Panthère in containers)
147147
* `PANTHERE_WEB_SERVER_DIR`: to change the project's document root (default to `public/`)
148+
* `PANTHERE_CHROME_DRIVER_BINARY`: to use another `chromedriver` binary, instead of relying on the ones already provided by Panthère
148149

149150
## Docker Integration
150151

src/ProcessManager/ChromeManager.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class ChromeManager implements BrowserManagerInterface
3232

3333
public function __construct(?string $chromeDriverBinary = null, ?array $arguments = null, array $options = [])
3434
{
35-
$this->process = new Process([$chromeDriverBinary ?? $this->findChromeDriverBinary()], null, null, null, null);
35+
$this->process = new Process([$chromeDriverBinary ?: $this->findChromeDriverBinary()], null, null, null, null);
3636
$this->arguments = $arguments ?? $this->getDefaultArguments();
3737
$this->options = \array_merge($this->getDefaultOptions(), $options);
3838
}
@@ -66,6 +66,10 @@ public function quit(): void
6666

6767
private function findChromeDriverBinary(): string
6868
{
69+
if ($binary = $_SERVER['PANTHERE_CHROME_DRIVER_BINARY'] ?? null) {
70+
return $binary;
71+
}
72+
6973
switch (PHP_OS_FAMILY) {
7074
case 'Windows':
7175
return __DIR__.'/../../chromedriver-bin/chromedriver.exe';

0 commit comments

Comments
 (0)