Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ matrix:
addons:
firefox: latest

# Stable Chrome + Chromedriver inside Travis environment via Selenium server proxy
- name: 'Chrome stable on Travis; via Selenium server'
# Stable Chrome + Chromedriver (W3C mode) inside Travis environment via Selenium server proxy
- name: 'Chrome stable on Travis (W3C protocol); via Selenium server'
php: '7.3'
env:
- BROWSER_NAME="chrome"
- CHROME_HEADLESS="1"
addons:
chrome: stable

# Stable Chrome + Chromedriver inside Travis environment directly via Chromedriver
- name: 'Chrome stable on Travis; no Selenium server'
# Stable Chrome + Chromedriver (W3C mode) inside Travis environment directly via Chromedriver
- name: 'Chrome stable on Travis (W3C protocol); no Selenium server'
php: '7.3'
env:
- BROWSER_NAME="chrome"
Expand All @@ -73,6 +73,17 @@ matrix:
addons:
chrome: stable

# Stable Chrome + Chromedriver (JsonWire OSS mode) inside Travis environment directly via Chromedriver
- name: 'Chrome stable on Travis (OSS protocol); no Selenium server'
php: '7.3'
env:
- BROWSER_NAME="chrome"
- CHROME_HEADLESS="1"
- CHROMEDRIVER="1"
- DISABLE_W3C_PROTOCOL="1"
addons:
chrome: stable

# Saucelabs builds
- php: '7.3'
env: SAUCELABS=1 BROWSER_NAME="firefox" VERSION="47.0" PLATFORM="Windows 10"
Expand Down
17 changes: 0 additions & 17 deletions lib/Remote/RemoteWebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,6 @@ public static function create(

$desired_capabilities = self::castToDesiredCapabilitiesObject($desired_capabilities);

// Hotfix: W3C WebDriver protocol is not yet supported by php-webdriver, so we must force Chromedriver to
// not use the W3C protocol by default (which is what Chromedriver does starting with version 75).
if ($desired_capabilities->getBrowserName() === WebDriverBrowserType::CHROME
&& mb_strpos($selenium_server_url, 'browserstack') === false // see https://github.com/facebook/php-webdriver/issues/644
) {
$currentChromeOptions = $desired_capabilities->getCapability(ChromeOptions::CAPABILITY);
$chromeOptions = !empty($currentChromeOptions) ? $currentChromeOptions : new ChromeOptions();

if ($chromeOptions instanceof ChromeOptions && !isset($chromeOptions->toArray()['w3c'])) {
$chromeOptions->setExperimentalOption('w3c', false);
} elseif (is_array($chromeOptions) && !isset($chromeOptions['w3c'])) {
$chromeOptions['w3c'] = false;
}

$desired_capabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions);
}

$executor = new HttpCommandExecutor($selenium_server_url, $http_proxy, $http_proxy_port);
if ($connection_timeout_in_ms !== null) {
$executor->setConnectionTimeout($connection_timeout_in_ms);
Expand Down
8 changes: 3 additions & 5 deletions tests/functional/RemoteWebDriverFindElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ public function testShouldFindMultipleElements()
*/
public function testEscapeCssSelector()
{
if (getenv('GECKODRIVER') !== '1') {
$this->markTestSkipped(
'CSS selectors containing special characters are not supported by the legacy protocol'
);
}
self::skipForJsonWireProtocol(
'CSS selectors containing special characters are not supported by the legacy protocol'
);

$this->driver->get($this->getTestPageUrl('escape_css.html'));

Expand Down
1 change: 0 additions & 1 deletion tests/functional/RemoteWebDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public function testShouldCloseWindow()
$this->driver->get($this->getTestPageUrl('open_new_window.html'));
$this->driver->findElement(WebDriverBy::cssSelector('a'))->click();

// Mandatory for Geckodriver
$this->driver->wait()->until(WebDriverExpectedCondition::numberOfWindowsToBe(2));

$this->assertCount(2, $this->driver->getWindowHandles());
Expand Down
4 changes: 1 addition & 3 deletions tests/functional/RemoteWebElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ public function testShouldSubmitFormByClickOnSubmitInput()
*/
public function testShouldCompareEqualsElement()
{
if (getenv('GECKODRIVER') === '1') {
$this->markTestSkipped('"equals" is not supported by the W3C specification');
}
self::skipForW3cProtocol('"equals" is not supported by the W3C specification');

$this->driver->get($this->getTestPageUrl('index.html'));

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/WebDriverActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testShouldClickOnElement()
$logs = ['mouseover item-1', 'mousedown item-1', 'mouseup item-1', 'click item-1'];
$loggedEvents = $this->retrieveLoggedEvents();

if ('1' === getenv('GECKODRIVER')) {
if (getenv('GECKODRIVER') === '1') {
$loggedEvents = array_slice($loggedEvents, 0, count($logs));
// Firefox sometimes triggers some extra events
// it's not related to Geckodriver, it's Firefox's own behavior
Expand Down Expand Up @@ -77,7 +77,7 @@ public function testShouldClickAndHoldOnElementAndRelease()
->release()
->perform();

if ('1' === getenv('GECKODRIVER')) {
if (self::isW3cProtocolBuild()) {
$this->assertArraySubset(['mouseover item-1', 'mousedown item-1'], $this->retrieveLoggedEvents());
} else {
$this->assertSame(
Expand Down
31 changes: 31 additions & 0 deletions tests/functional/WebDriverTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ protected function setUp()
$chromeOptions = new ChromeOptions();
// --no-sandbox is a workaround for Chrome crashing: https://github.com/SeleniumHQ/selenium/issues/4961
$chromeOptions->addArguments(['--headless', 'window-size=1024,768', '--no-sandbox']);

if (getenv('DISABLE_W3C_PROTOCOL')) {
$chromeOptions->setExperimentalOption('w3c', false);
}

$this->desiredCapabilities->setCapability(ChromeOptions::CAPABILITY, $chromeOptions);
} elseif (getenv('GECKODRIVER') === '1') {
$this->serverUrl = 'http://localhost:4444';
Expand Down Expand Up @@ -97,6 +102,32 @@ public static function isSauceLabsBuild()
return getenv('SAUCELABS') ? true : false;
}

/**
* @return bool
*/
public static function isW3cProtocolBuild()
{
return getenv('GECKODRIVER') === '1'
|| (getenv('BROWSER_NAME') === 'chrome'
&& getenv('DISABLE_W3C_PROTOCOL') !== '1'
&& !self::isSauceLabsBuild());
}

public static function skipForW3cProtocol($message = 'Not supported by W3C specification')
{
if (static::isW3cProtocolBuild()) {
static::markTestSkipped($message);
}
}

public static function skipForJsonWireProtocol($message = 'Not supported by JsonWire protocol')
{
if (getenv('GECKODRIVER') !== '1'
&& (getenv('CHROMEDRIVER') !== '1' || getenv('DISABLE_W3C_PROTOCOL') === '1')) {
static::markTestSkipped($message);
}
}

/**
* Get the URL of given test HTML on running webserver.
*
Expand Down