Skip to content

Commit 4ff3de7

Browse files
committed
Update to WebDriver: W3C Editor's Draft 17 June 2021
1 parent edd980a commit 4ff3de7

File tree

7 files changed

+143
-2
lines changed

7 files changed

+143
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ WebDriver for Selenium 2
33
This WebDriver client implementation is based on Facebook's [php-webdriver](https://github.com/facebook/php-webdriver/) project by Justin Bishop.
44

55
Distinguishing features:
6-
* Up-to-date with [WebDriver: W3C Living Document 31 December 2019](https://w3c.github.io/webdriver/)
6+
* Up-to-date with [WebDriver: W3C Editor's Draft 17 June 2021](https://w3c.github.io/webdriver/)
77
* Up-to-date with [Selenium 2 JSON Wire Protocol](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol) (including WebDriver commands yet to be documented).
8-
* In the *master* branch, class names and file organization follow PSR-0 conventions for php 5.3+ namespaces.
8+
* In the *master* branch, class names and file organization follow PSR-0 conventions for namespaces.
99
* Coding style follows PSR-1, PSR-2, and Symfony2 conventions.
1010
* Auto-generate API documentation via [phpDocumentor 2.x](http://phpdoc.org/).
1111

lib/WebDriver/Element.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
* @method array rect() Get Element Rect
4949
* @method array active() Get Active Element
5050
* @method array screenshot() Take Element Screenshot
51+
* @method array computedrole() Get Computed Role
52+
* @method array computedlabel() Get Computed Label
5153
*/
5254
final class Element extends Container
5355
{
@@ -70,6 +72,8 @@ protected function methods()
7072
'rect' => array('GET'),
7173
'active' => array('GET'),
7274
'screenshot' => array('GET'),
75+
'computedrole' => array('GET'),
76+
'computedlabel' => array('GET'),
7377

7478
// Legacy JSON Wire Protocol
7579
'submit' => array('POST'),
@@ -126,6 +130,20 @@ public function getID()
126130
return $this->id;
127131
}
128132

133+
/**
134+
* Get element shadow root: /session/:sessionId/element/:elementId/shadow
135+
*
136+
* shadow root method chaining, e.g.,
137+
* - $element->method()
138+
*
139+
* @return \WebDriver\Shadow
140+
*
141+
*/
142+
public function shadow()
143+
{
144+
return new Shadow($this->url . '/shadow', $this->w3c);
145+
}
146+
129147
/**
130148
* {@inheritdoc}
131149
*/

lib/WebDriver/Exception.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ abstract class Exception extends \Exception
125125
self::UNKNOWN_LOCATOR_STRATEGY => array('UnknownLocatorStrategy', 'This locator strategy is not supported.'),
126126

127127
// @link https://w3c.github.io/webdriver/#errors
128+
'detached shadow root' => array('DetachedShadowRoot', 'A command failed because the referenced shadow root is no longer attached to the DOM.'),
128129
'element click intercepted' => array('ElementClickIntercepted', 'The Element Click command could not be completed because the element receiving the events is obscuring the element that was requested clicked.'),
129130
'element not interactable' => array('ElementNotInteractable', 'A command could not be completed because the element is not pointer- or keyboard interactable.'),
130131
'insecure certificate' => array('InsecureCertificate', 'Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate.'),
@@ -139,6 +140,7 @@ abstract class Exception extends \Exception
139140
'no such cookie' => array('NoSuchCookie', 'No cookie matching the given path name was found amongst the associated cookies of the current browsing context\'s active document.'),
140141
'no such element' => array('NoSuchElement', 'An element could not be located on the page using the given search parameters.'),
141142
'no such frame' => array('NoSuchFrame', 'A command to switch to a frame could not be satisfied because the frame could not be found.'),
143+
'no such shadow root' => array('NoSuchShadowRoot', 'The element does not have a shadow root.'),
142144
'no such window' => array('NoSuchWindow', 'A command to switch to a window could not be satisfied because the window could not be found.'),
143145
'script timeout' => array('ScriptTimeout', 'A script did not complete before its timeout expired.'),
144146
'script timeout error' => array('ScriptTimeout', 'A script did not complete before its timeout expired.'),
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2004-2021 Facebook. All Rights Reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @package WebDriver
19+
*
20+
* @author Justin Bishop <[email protected]>
21+
* @author Anthon Pang <[email protected]>
22+
*/
23+
24+
namespace WebDriver\Exception;
25+
26+
use WebDriver\Exception as BaseException;
27+
28+
/**
29+
* WebDriver\Exception\DetachedShadowRoot class
30+
*
31+
* @package WebDriver
32+
*/
33+
final class DetachedShadowRoot extends BaseException
34+
{
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2004-2021 Facebook. All Rights Reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @package WebDriver
19+
*
20+
* @author Justin Bishop <[email protected]>
21+
* @author Anthon Pang <[email protected]>
22+
*/
23+
24+
namespace WebDriver\Exception;
25+
26+
use WebDriver\Exception as BaseException;
27+
28+
/**
29+
* WebDriver\Exception\NoSuchShadowRoot class
30+
*
31+
* @package WebDriver
32+
*/
33+
final class NoSuchShadowRoot extends BaseException
34+
{
35+
}

lib/WebDriver/Session.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
* @method void postBrowser_connection($jsonState) Set browser online.
6262
* @method array postActions() Perform Actions
6363
* @method array deleteActions() Release Actions
64+
* @method array print() Print Page
6465
*/
6566
final class Session extends Container
6667
{
@@ -84,6 +85,7 @@ protected function methods()
8485
'source' => array('GET'),
8586
'title' => array('GET'),
8687
'actions' => array('POST', 'DELETE'),
88+
'print' => array('POST'),
8789

8890
// specific to Java SeleniumServer
8991
'file' => array('POST'),

lib/WebDriver/Shadow.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2021-2021 Anthon Pang. All Rights Reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @package WebDriver
19+
*
20+
* @author Anthon Pang <[email protected]>
21+
*/
22+
23+
namespace WebDriver;
24+
25+
/**
26+
* WebDriver\Shadow class
27+
*
28+
* @package WebDriver
29+
*/
30+
final class Shadow extends Container
31+
{
32+
const SHADOW_ROOT_ID = 'shadow-6066-11e4-a52e-4f735466cecf';
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
protected function methods()
38+
{
39+
return array();
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
protected function getElementPath($elementId)
46+
{
47+
return sprintf('%s/element/%s', $this->url, $elementId);
48+
}
49+
}

0 commit comments

Comments
 (0)