From 41da6d58679c1adb62d8e8b9820672bc9cf00578 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 10 Oct 2018 14:06:06 +0200 Subject: [PATCH 1/2] Use chrome on Travis rather than Firefox for most jobs On Trusty, the preinstalled Firefox version is newer than the latest version supported by the FirefoxDriver of Selenium 2, and requires using the W3C protocol. But we don't support this protocol yet. --- .travis.yml | 8 +++++--- bin/run-selenium.sh | 12 +++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 94e46a73..8fe2d1c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,22 +11,24 @@ php: [5.4, 5.5, 5.6, 7.0, 7.1, 7.2] env: global: - WEBDRIVER=selenium + - WEB_FIXTURES_BROWSER=chrome matrix: fast_finish: true include: - php: 7.0 - env: WEBDRIVER=selenium-remote + env: WEBDRIVER=selenium-remote WEB_FIXTURES_BROWSER=firefox sudo: required services: - docker - php: 5.3 dist: precise # Force using PHP 5.6 for the test server as PHP 5.3 does not have the builtin webserver - env: MINK_PHP_BIN=~/.phpenv/versions/5.6/bin/php + # Use Selenium 2 and Firefox when running on the precise infra, as it has a version of Firefox old enough. + env: MINK_PHP_BIN=~/.phpenv/versions/5.6/bin/php SELENIUM_VERSION=2 WEB_FIXTURES_BROWSER=firefox before_script: - - sh bin/run-"$WEBDRIVER".sh + - bash bin/run-"$WEBDRIVER".sh - composer install diff --git a/bin/run-selenium.sh b/bin/run-selenium.sh index e846d3ae..045a4328 100644 --- a/bin/run-selenium.sh +++ b/bin/run-selenium.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -e echo ' Starting XVFB' @@ -6,6 +6,12 @@ sh -e /etc/init.d/xvfb start export DISPLAY=:99.0 echo ' Downloading selenium' -curl -L http://selenium-release.storage.googleapis.com/2.52/selenium-server-standalone-2.52.0.jar > selenium.jar +if [ "${SELENIUM_VERSION:-3}" = "2" ]; then + curl -L http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar > selenium.jar +else + curl -L https://selenium-release.storage.googleapis.com/3.14/selenium-server-standalone-3.14.0.jar > selenium.jar +fi; +curl -L -O https://chromedriver.storage.googleapis.com/2.42/chromedriver_linux64.zip +unzip chromedriver_linux64.zip echo ' Running selenium' -java -jar selenium.jar -log /tmp/webdriver.log > /tmp/webdriver_output.txt 2>&1 & +java -Dwebdriver.chrome.driver="$PWD/chromedriver" -jar selenium.jar -log /tmp/webdriver.log > /tmp/webdriver_output.txt 2>&1 & From 30a74295704703b27095ec643303a2a5ff905dc6 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 10 Oct 2018 18:18:53 +0200 Subject: [PATCH 2/2] Disable the chrome sandbox when running tests on Travis --- tests/Selenium2Config.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/Selenium2Config.php b/tests/Selenium2Config.php index b5da1bff..27bd03af 100644 --- a/tests/Selenium2Config.php +++ b/tests/Selenium2Config.php @@ -19,7 +19,14 @@ public function createDriver() $browser = getenv('WEB_FIXTURES_BROWSER') ?: 'firefox'; $seleniumHost = $_SERVER['DRIVER_URL']; - return new Selenium2Driver($browser, null, $seleniumHost); + $capabilities = array(); + + // disable the Chrome sandbox when running on Travis as it is incompatible with their container environment + if ($browser === 'chrome' && 'true' === getenv('TRAVIS')) { + $capabilities['chrome']['args'] = array('--no-sandbox'); + } + + return new Selenium2Driver($browser, $capabilities, $seleniumHost); } /**