Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit e8561c2

Browse files
authored
Merge pull request #685 from OndraM/feature/saucelabs-w3c
Use W3C protocol on part of Sauce Labs builds
2 parents e9f4ec8 + a419816 commit e8561c2

File tree

8 files changed

+57
-39
lines changed

8 files changed

+57
-39
lines changed

.travis.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ matrix:
5959
php: '7.3'
6060
env:
6161
- BROWSER_NAME="chrome"
62-
- CHROME_HEADLESS="1"
6362
addons:
6463
chrome: stable
6564

@@ -68,7 +67,6 @@ matrix:
6867
php: '7.3'
6968
env:
7069
- BROWSER_NAME="chrome"
71-
- CHROME_HEADLESS="1"
7270
- CHROMEDRIVER="1"
7371
addons:
7472
chrome: stable
@@ -78,15 +76,15 @@ matrix:
7876
php: '7.3'
7977
env:
8078
- BROWSER_NAME="chrome"
81-
- CHROME_HEADLESS="1"
8279
- CHROMEDRIVER="1"
8380
- DISABLE_W3C_PROTOCOL="1"
8481
addons:
8582
chrome: stable
8683

8784
# Saucelabs builds
88-
- php: '7.3'
89-
env: SAUCELABS=1 BROWSER_NAME="firefox" VERSION="47.0" PLATFORM="Windows 10"
85+
- name: 'Sauce Labs, Firefox 47, OSS protocol'
86+
php: '7.3'
87+
env: SAUCELABS=1 BROWSER_NAME="firefox" VERSION="47.0" PLATFORM="Windows 10" DISABLE_W3C_PROTOCOL="1"
9088
before_script:
9189
- php -S 127.0.0.1:8000 -t tests/functional/web/ &>>./logs/php-server.log &
9290
- until $(echo | nc localhost 8000); do sleep 1; echo waiting for PHP server on port 8000...; done; echo "PHP server started"
@@ -95,8 +93,9 @@ matrix:
9593
jwt:
9694
secure: HPq5xFhosa1eSGnaRdJzeyEuaE0mhRlG1gf3G7+dKS0VniF30husSyrxZhbGCCKBGxmIySoAQzd43BCwL69EkUEVKDN87Cpid1Ce9KrSfU3cnN8XIb+4QINyy7x1a47RUAfaaOEx53TrW0ShalvjD+ZwDE8LrgagSox6KQ+nQLE=
9795

98-
- php: '7.3'
99-
env: SAUCELABS=1 BROWSER_NAME="chrome" VERSION="74.0" PLATFORM="Windows 10" # 74 is the last version which don't use W3C WebDriver by default
96+
- name: 'Sauce Labs, Chrome 74, OSS protocol'
97+
php: '7.3'
98+
env: SAUCELABS=1 BROWSER_NAME="chrome" VERSION="74.0" PLATFORM="Windows 10" DISABLE_W3C_PROTOCOL="1" # 74 is the last version which don't use W3C WebDriver by default
10099
before_script:
101100
- php -S 127.0.0.1:8000 -t tests/functional/web/ &>>./logs/php-server.log &
102101
- until $(echo | nc localhost 8000); do sleep 1; echo waiting for PHP server on port 8000...; done; echo "PHP server started"
@@ -105,8 +104,9 @@ matrix:
105104
jwt:
106105
secure: HPq5xFhosa1eSGnaRdJzeyEuaE0mhRlG1gf3G7+dKS0VniF30husSyrxZhbGCCKBGxmIySoAQzd43BCwL69EkUEVKDN87Cpid1Ce9KrSfU3cnN8XIb+4QINyy7x1a47RUAfaaOEx53TrW0ShalvjD+ZwDE8LrgagSox6KQ+nQLE=
107106

108-
- php: '7.3'
109-
env: SAUCELABS=1 BROWSER_NAME="chrome" VERSION="75.0" PLATFORM="Windows 10"
107+
- name: 'Sauce Labs, Chrome latest, W3C protocol'
108+
php: '7.3'
109+
env: SAUCELABS=1 BROWSER_NAME="chrome" VERSION="latest" PLATFORM="Windows 10"
110110
before_script:
111111
- php -S 127.0.0.1:8000 -t tests/functional/web/ &>>./logs/php-server.log &
112112
- until $(echo | nc localhost 8000); do sleep 1; echo waiting for PHP server on port 8000...; done; echo "PHP server started"
@@ -115,8 +115,9 @@ matrix:
115115
jwt:
116116
secure: HPq5xFhosa1eSGnaRdJzeyEuaE0mhRlG1gf3G7+dKS0VniF30husSyrxZhbGCCKBGxmIySoAQzd43BCwL69EkUEVKDN87Cpid1Ce9KrSfU3cnN8XIb+4QINyy7x1a47RUAfaaOEx53TrW0ShalvjD+ZwDE8LrgagSox6KQ+nQLE=
117117

118-
- php: '7.3'
119-
env: SAUCELABS=1 BROWSER_NAME="MicrosoftEdge" VERSION="16.16299" PLATFORM="Windows 10"
118+
- name: 'Sauce Labs, Edge latest, W3C protocol'
119+
php: '7.3'
120+
env: SAUCELABS=1 BROWSER_NAME="MicrosoftEdge" VERSION="latest" PLATFORM="Windows 10"
120121
before_script:
121122
- php -S 127.0.0.1:8000 -t tests/functional/web/ &>>./logs/php-server.log &
122123
- until $(echo | nc localhost 8000); do sleep 1; echo waiting for PHP server on port 8000...; done; echo "PHP server started"

lib/Remote/RemoteWebElement.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ public function isSelected()
358358
public function sendKeys($value)
359359
{
360360
$local_file = $this->fileDetector->getLocalFile($value);
361+
361362
if ($local_file === null) {
362363
if ($this->isW3cCompliant) {
363364
$params = [
@@ -370,22 +371,18 @@ public function sendKeys($value)
370371
':id' => $this->id,
371372
];
372373
}
373-
374-
$this->executor->execute(DriverCommand::SEND_KEYS_TO_ELEMENT, $params);
375-
376-
return $this;
377-
}
378-
379-
if ($this->isW3cCompliant) {
380-
$params = [
381-
'text' => $local_file,
382-
':id' => $this->id,
383-
];
384374
} else {
385-
$params = [
386-
'value' => WebDriverKeys::encode($this->upload($local_file)),
387-
':id' => $this->id,
388-
];
375+
if ($this->isW3cCompliant) {
376+
$params = [
377+
'text' => $local_file,
378+
':id' => $this->id,
379+
];
380+
} else {
381+
$params = [
382+
'value' => WebDriverKeys::encode($this->upload($local_file)),
383+
':id' => $this->id,
384+
];
385+
}
389386
}
390387

391388
$this->executor->execute(DriverCommand::SEND_KEYS_TO_ELEMENT, $params);

tests/functional/FileUploadTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class FileUploadTest extends WebDriverTestCase
2626
/**
2727
* @group exclude-edge
2828
* https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/6052385/
29+
* @group exclude-saucelabs
30+
* W3C protocol does not support remote file upload: https://github.com/w3c/webdriver/issues/1355
2931
*/
3032
public function testShouldUploadAFile()
3133
{

tests/functional/WebDriverAlertTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ class WebDriverAlertTest extends WebDriverTestCase
2525
{
2626
protected function setUp()
2727
{
28-
if (getenv('CHROME_HEADLESS') === '1') {
29-
// Alerts in headless mode should be available in next Chrome version (61), see:
30-
// https://bugs.chromium.org/p/chromium/issues/detail?id=718235
31-
$this->markTestSkipped('Alerts not yet supported by headless Chrome');
32-
}
33-
3428
parent::setUp();
3529

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

tests/functional/WebDriverCheckboxesTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/**
2121
* @covers \Facebook\WebDriver\WebDriverCheckboxes
2222
* @covers \Facebook\WebDriver\AbstractWebDriverCheckboxOrRadio
23+
* @group exclude-edge
2324
*/
2425
class WebDriverCheckboxesTest extends WebDriverTestCase
2526
{

tests/functional/WebDriverRadiosTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/**
2222
* @covers \Facebook\WebDriver\WebDriverRadios
2323
* @covers \Facebook\WebDriver\AbstractWebDriverCheckboxOrRadio
24+
* @group exclude-edge
2425
*/
2526
class WebDriverRadiosTest extends WebDriverTestCase
2627
{

tests/functional/WebDriverTestCase.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ public static function isSauceLabsBuild()
112112
public static function isW3cProtocolBuild()
113113
{
114114
return getenv('GECKODRIVER') === '1'
115-
|| (getenv('BROWSER_NAME') === 'chrome'
116-
&& getenv('DISABLE_W3C_PROTOCOL') !== '1'
117-
&& !self::isSauceLabsBuild());
115+
|| (getenv('BROWSER_NAME') === 'chrome' && getenv('DISABLE_W3C_PROTOCOL') !== '1')
116+
|| (self::isSauceLabsBuild() && getenv('DISABLE_W3C_PROTOCOL') !== '1');
118117
}
119118

120119
public static function skipForW3cProtocol($message = 'Not supported by W3C specification')
@@ -153,12 +152,32 @@ protected function setUpSauceLabs()
153152
$this->desiredCapabilities->setBrowserName(getenv('BROWSER_NAME'));
154153
$this->desiredCapabilities->setVersion(getenv('VERSION'));
155154
$this->desiredCapabilities->setPlatform(getenv('PLATFORM'));
156-
$this->desiredCapabilities->setCapability('name', get_class($this) . '::' . $this->getName());
157-
$this->desiredCapabilities->setCapability('tags', [get_class($this)]);
155+
$name = get_class($this) . '::' . $this->getName();
156+
$tags = [get_class($this)];
158157

159158
if (getenv('TRAVIS_JOB_NUMBER')) {
160-
$this->desiredCapabilities->setCapability('tunnel-identifier', getenv('TRAVIS_JOB_NUMBER'));
161-
$this->desiredCapabilities->setCapability('build', getenv('TRAVIS_JOB_NUMBER'));
159+
$tunnelIdentifier = getenv('TRAVIS_JOB_NUMBER');
160+
$build = getenv('TRAVIS_JOB_NUMBER');
161+
}
162+
163+
if (!getenv('DISABLE_W3C_PROTOCOL')) {
164+
$sauceOptions = [
165+
'name' => $name,
166+
'tags' => $tags,
167+
];
168+
if (isset($tunnelIdentifier, $build)) {
169+
$sauceOptions['tunnelIdentifier'] = $tunnelIdentifier;
170+
$sauceOptions['build'] = $build;
171+
}
172+
$this->desiredCapabilities->setCapability('sauce:options', (object) $sauceOptions);
173+
} else {
174+
$this->desiredCapabilities->setCapability('name', $name);
175+
$this->desiredCapabilities->setCapability('tags', $tags);
176+
177+
if (isset($tunnelIdentifier, $build)) {
178+
$this->desiredCapabilities->setCapability('tunnel-identifier', $tunnelIdentifier);
179+
$this->desiredCapabilities->setCapability('build', $build);
180+
}
162181
}
163182
}
164183
}

tests/functional/WebDriverTimeoutsTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
*/
2727
class WebDriverTimeoutsTest extends WebDriverTestCase
2828
{
29+
/**
30+
* @group exclude-saucelabs
31+
*/
2932
public function testShouldFailGettingDelayedElementWithoutWait()
3033
{
3134
$this->driver->get($this->getTestPageUrl('delayed_element.html'));

0 commit comments

Comments
 (0)