Skip to content

Commit fda6f7f

Browse files
committed
Use a workaround for Chrome crashing on startup on Travis
SeleniumHQ/selenium#4961
1 parent 7c69d51 commit fda6f7f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/functional/Chrome/ChromeDriverTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace Facebook\WebDriver\Chrome;
1717

18+
use Facebook\WebDriver\Remote\DesiredCapabilities;
1819
use Facebook\WebDriver\Remote\RemoteWebDriver;
1920
use Facebook\WebDriver\Remote\Service\DriverCommandExecutor;
2021
use PHPUnit\Framework\TestCase;
@@ -47,7 +48,13 @@ public function testShouldStartChromeDriver()
4748
// The createDefaultService() method expect path to the executable to be present in the environment variable
4849
putenv(ChromeDriverService::CHROME_DRIVER_EXE_PROPERTY . '=' . getenv('CHROMEDRIVER_PATH'));
4950

50-
$this->driver = ChromeDriver::start();
51+
// Add --no-sandbox as a workaround for Chrome crashing: https://github.com/SeleniumHQ/selenium/issues/4961
52+
$chromeOptions = new ChromeOptions();
53+
$chromeOptions->addArguments(['--no-sandbox']);
54+
$desiredCapabilities = DesiredCapabilities::chrome();
55+
$desiredCapabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions);
56+
57+
$this->driver = ChromeDriver::start($desiredCapabilities);
5158

5259
$this->assertInstanceOf(ChromeDriver::class, $this->driver);
5360
$this->assertInstanceOf(DriverCommandExecutor::class, $this->driver->getCommandExecutor());

tests/functional/WebDriverTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ protected function setUp()
5555

5656
if ($browserName === WebDriverBrowserType::CHROME) {
5757
$chromeOptions = new ChromeOptions();
58-
$chromeOptions->addArguments(['--headless', 'window-size=1024,768']);
58+
// --no-sandbox is a workaround for Chrome crashing: https://github.com/SeleniumHQ/selenium/issues/4961
59+
$chromeOptions->addArguments(['--headless', 'window-size=1024,768', '--no-sandbox']);
5960
$this->desiredCapabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions);
6061
}
6162

0 commit comments

Comments
 (0)