Skip to content

Commit 6df9fe9

Browse files
committed
Backport exceptions from master branch
1 parent 48524f2 commit 6df9fe9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+452
-453
lines changed

lib/WebDriver/Exception.php

Lines changed: 60 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
<?php
2+
23
/**
3-
* Copyright 2004-2017 Facebook. All Rights Reserved.
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
4+
* @copyright 2004 Meta Platforms, Inc.
5+
* @license Apache-2.0
166
*
177
* @package WebDriver
188
*
199
* @author Justin Bishop <jubishop@gmail.com>
20-
* @author Anthon Pang <apang@softwaredevelopment.ca>
2110
*/
2211

2312
namespace WebDriver;
@@ -32,18 +21,16 @@ abstract class Exception extends \Exception
3221
/**
3322
* Response status codes
3423
*
35-
* @link http://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes
24+
* @see https://github.com/SeleniumHQ/selenium/blob/trunk/java/src/org/openqa/selenium/remote/ErrorCodes.java
3625
*/
3726
const SUCCESS = 0;
3827
const NO_SUCH_DRIVER = 6;
3928
const NO_SUCH_ELEMENT = 7;
4029
const NO_SUCH_FRAME = 8;
4130
const UNKNOWN_COMMAND = 9;
4231
const STALE_ELEMENT_REFERENCE = 10;
43-
const ELEMENT_NOT_VISIBLE = 11;
4432
const INVALID_ELEMENT_STATE = 12;
4533
const UNKNOWN_ERROR = 13;
46-
const ELEMENT_IS_NOT_SELECTABLE = 15;
4734
const JAVASCRIPT_ERROR = 17;
4835
const XPATH_LOOKUP_ERROR = 19;
4936
const TIMEOUT = 21;
@@ -59,6 +46,15 @@ abstract class Exception extends \Exception
5946
const INVALID_SELECTOR = 32;
6047
const SESSION_NOT_CREATED = 33;
6148
const MOVE_TARGET_OUT_OF_BOUNDS = 34;
49+
const INVALID_XPATH_SELECTOR = 51;
50+
const INVALID_XPATH_SELECTOR_RETURN_TYPER = 52;
51+
const ELEMENT_NOT_INTERACTABLE = 60;
52+
const INVALID_ARGUMENT = 61;
53+
const NO_SUCH_COOKIE = 62;
54+
const UNABLE_TO_CAPTURE_SCREEN = 63;
55+
const ELEMENT_CLICK_INTERCEPTED = 64;
56+
const NO_SUCH_SHADOW_ROOT = 65;
57+
const METHOD_NOT_ALLOWED = 405;
6258

6359
// obsolete
6460
const INDEX_OUT_OF_BOUNDS = 1;
@@ -68,8 +64,10 @@ abstract class Exception extends \Exception
6864
const NO_STRING_WRAPPER = 5;
6965
const OBSOLETE_ELEMENT = 10;
7066
const ELEMENT_NOT_DISPLAYED = 11;
67+
const ELEMENT_NOT_VISIBLE = 11;
7168
const UNHANDLED = 13;
7269
const EXPECTED = 14;
70+
const ELEMENT_IS_NOT_SELECTABLE = 15;
7371
const ELEMENT_NOT_SELECTABLE = 15;
7472
const NO_SUCH_DOCUMENT = 16;
7573
const UNEXPECTED_JAVASCRIPT = 17;
@@ -123,6 +121,50 @@ abstract class Exception extends \Exception
123121
self::UNEXPECTED_PARAMETERS => array('UnexpectedParameters', 'This command does not expect this number of parameters.'),
124122
self::INVALID_REQUEST => array('InvalidRequest', 'This command does not support this HTTP request method.'),
125123
self::UNKNOWN_LOCATOR_STRATEGY => array('UnknownLocatorStrategy', 'This locator strategy is not supported.'),
124+
self::INVALID_XPATH_SELECTOR => array('InvalidSelector', 'Argument was an invalid selector.'),
125+
self::INVALID_XPATH_SELECTOR_RETURN_TYPER => array('InvalidSelector', 'Argument was an invalid selector.'),
126+
self::ELEMENT_NOT_INTERACTABLE => array('ElementNotInteractable', 'A command could not be completed because the element is not pointer- or keyboard interactable.'),
127+
self::INVALID_ARGUMENT => array('InvalidArgument', 'The arguments passed to a command are either invalid or malformed.'),
128+
self::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.'),
129+
self::UNABLE_TO_CAPTURE_SCREEN => array('UnableToCaptureScreen', 'A screen capture was made impossible.'),
130+
self::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.'),
131+
self::NO_SUCH_SHADOW_ROOT => array('NoSuchShadowRoot', 'The element does not have a shadow root.'),
132+
self::METHOD_NOT_ALLOWED => array('UnsupportedOperation', 'Indicates that a command that should have executed properly cannot be supported for some reason.'),
133+
134+
// @ss https://w3c.github.io/webdriver/#errors
135+
'element not interactable' => array('ElementNotInteractable', 'A command could not be completed because the element is not pointer- or keyboard interactable.'),
136+
'element not selectable' => array('ElementIsNotSelectable', 'An attempt was made to select an element that cannot be selected.'),
137+
'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.'),
138+
'invalid argument' => array('InvalidArgument', 'The arguments passed to a command are either invalid or malformed.'),
139+
'invalid cookie domain' => array('InvalidCookieDomain', 'An illegal attempt was made to set a cookie under a different domain than the current page.'),
140+
'invalid coordinates' => array('InvalidCoordinates', 'The coordinates provided to an interactions operation are invalid.'),
141+
'invalid element state' => array('InvalidElementState', 'A command could not be completed because the element is in an invalid state, e.g. attempting to clear an element that isn\'t both editable and resettable.'),
142+
'invalid selector' => array('InvalidSelector', 'Argument was an invalid selector.'),
143+
'invalid session id' => array('InvalidSessionID', 'Occurs if the given session id is not in the list of active sessions, meaning the session either does not exist or that it\'s not active.'),
144+
'javascript error' => array('JavaScriptError', 'An error occurred while executing JavaScript supplied by the user.'),
145+
'move target out of bounds' => array('MoveTargetOutOfBounds', 'The target for mouse interaction is not in the browser\'s viewport and cannot be brought into that viewport.'),
146+
'no such alert' => array('NoSuchAlert', 'An attempt was made to operate on a modal dialog when one was not open.'),
147+
'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.'),
148+
'no such element' => array('NoSuchElement', 'An element could not be located on the page using the given search parameters.'),
149+
'no such frame' => array('NoSuchFrame', 'A command to switch to a frame could not be satisfied because the frame could not be found.'),
150+
'no such window' => array('NoSuchWindow', 'A command to switch to a window could not be satisfied because the window could not be found.'),
151+
'script timeout' => array('ScriptTimeout', 'A script did not complete before its timeout expired.'),
152+
'session not created' => array('SessionNotCreated', 'A new session could not be created.'),
153+
'stale element reference' => array('StaleElementReference', 'A command failed because the referenced element is no longer attached to the DOM.'),
154+
'timeout' => array('Timeout', 'An operation did not complete before its timeout expired.'),
155+
'unable to capture screen' => array('UnableToCaptureScreen', 'A screen capture was made impossible.'),
156+
'unable to set cookie' => array('UnableToSetCookie', 'A command to set a cookie\'s value could not be satisfied.'),
157+
'unexpected alert open' => array('UnexpectedAlertOpen', 'A modal dialog was open, blocking this operation.'),
158+
'unknown command' => array('UnknownCommand', 'A command could not be executed because the remote end is not aware of it.'),
159+
'unknown error' => array('UnknownError', 'An unknown error occurred in the remote end while processing the command.'),
160+
'unknown method' => array('UnknownMethod', 'The requested command matched a known URL but did not match an method for that URL.'),
161+
'unsupported operation' => array('UnsupportedOperation', 'Indicates that a command that should have executed properly cannot be supported for some reason.'),
162+
163+
// obsolete
164+
'detached shadow root' => array('DetachedShadowRoot', 'A command failed because the referenced shadow root is no longer attached to the DOM.'),
165+
'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.'),
166+
'no such shadow root' => array('NoSuchShadowRoot', 'The element does not have a shadow root.'),
167+
'script timeout error' => array('ScriptTimeout', 'A script did not complete before its timeout expired.'),
126168
);
127169

128170
/**
@@ -143,7 +185,7 @@ public static function factory($code, $message = null, $previousException = null
143185

144186
$errorDefinition = self::$errs[$code];
145187

146-
if (trim($message) === '') {
188+
if ($message === null || trim($message) === '') {
147189
$message = $errorDefinition[1];
148190
}
149191

lib/WebDriver/Exception/CurlExec.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
<?php
2+
23
/**
3-
* Copyright 2004-2017 Facebook. All Rights Reserved.
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
4+
* @copyright 2013 Anthon Pang
5+
* @license Apache-2.0
166
*
177
* @package WebDriver
188
*
19-
* @author Justin Bishop <jubishop@gmail.com>
209
* @author Anthon Pang <apang@softwaredevelopment.ca>
21-
* @author Gaetano Giunta <giunta.gaetano@gmail.com>
2210
*/
2311

2412
namespace WebDriver\Exception;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/**
4+
* @copyright 2013 Anthon Pang
5+
* @license Apache-2.0
6+
*
7+
* @package WebDriver
8+
*
9+
* @author Anthon Pang <apang@softwaredevelopment.ca>
10+
*/
11+
12+
namespace WebDriver\Exception;
13+
14+
use WebDriver\Exception as BaseException;
15+
16+
/**
17+
* WebDriver\Exception\DetachedShadowRoot class
18+
*
19+
* @package WebDriver
20+
*/
21+
final class DetachedShadowRoot extends BaseException
22+
{
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/**
4+
* @copyright 2019 Anthon Pang
5+
* @license Apache-2.0
6+
*
7+
* @package WebDriver
8+
*
9+
* @author Anthon Pang <apang@softwaredevelopment.ca>
10+
*/
11+
12+
namespace WebDriver\Exception;
13+
14+
use WebDriver\Exception as BaseException;
15+
16+
/**
17+
* WebDriver\Exception\ElementClickIntercepted class
18+
*
19+
* @package WebDriver
20+
*/
21+
final class ElementClickIntercepted extends BaseException
22+
{
23+
}

lib/WebDriver/Exception/ElementIsNotSelectable.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
<?php
2+
23
/**
3-
* Copyright 2004-2017 Facebook. All Rights Reserved.
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
4+
* @copyright 2013 Anthon Pang
5+
* @license Apache-2.0
166
*
177
* @package WebDriver
188
*
19-
* @author Justin Bishop <jubishop@gmail.com>
209
* @author Anthon Pang <apang@softwaredevelopment.ca>
2110
*/
2211

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/**
4+
* @copyright 2019 Anthon Pang
5+
* @license Apache-2.0
6+
*
7+
* @package WebDriver
8+
*
9+
* @author Anthon Pang <apang@softwaredevelopment.ca>
10+
*/
11+
12+
namespace WebDriver\Exception;
13+
14+
use WebDriver\Exception as BaseException;
15+
16+
/**
17+
* WebDriver\Exception\ElementNotInteractable class
18+
*
19+
* @package WebDriver
20+
*/
21+
final class ElementNotInteractable extends BaseException
22+
{
23+
}

lib/WebDriver/Exception/ElementNotVisible.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
<?php
2+
23
/**
3-
* Copyright 2004-2017 Facebook. All Rights Reserved.
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
4+
* @copyright 2013 Anthon Pang
5+
* @license Apache-2.0
166
*
177
* @package WebDriver
188
*
19-
* @author Justin Bishop <jubishop@gmail.com>
209
* @author Anthon Pang <apang@softwaredevelopment.ca>
2110
*/
2211

lib/WebDriver/Exception/IMEEngineActivationFailed.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
<?php
2+
23
/**
3-
* Copyright 2004-2017 Facebook. All Rights Reserved.
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
4+
* @copyright 2013 Anthon Pang
5+
* @license Apache-2.0
166
*
177
* @package WebDriver
188
*
19-
* @author Justin Bishop <jubishop@gmail.com>
209
* @author Anthon Pang <apang@softwaredevelopment.ca>
2110
*/
2211

lib/WebDriver/Exception/IMENotAvailable.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
<?php
2+
23
/**
3-
* Copyright 2004-2017 Facebook. All Rights Reserved.
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
4+
* @copyright 2013 Anthon Pang
5+
* @license Apache-2.0
166
*
177
* @package WebDriver
188
*
19-
* @author Justin Bishop <jubishop@gmail.com>
209
* @author Anthon Pang <apang@softwaredevelopment.ca>
2110
*/
2211

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/**
4+
* @copyright 2019 Anthon Pang
5+
* @license Apache-2.0
6+
*
7+
* @package WebDriver
8+
*
9+
* @author Anthon Pang <apang@softwaredevelopment.ca>
10+
*/
11+
12+
namespace WebDriver\Exception;
13+
14+
use WebDriver\Exception as BaseException;
15+
16+
/**
17+
* WebDriver\Exception\InsecureCertificate class
18+
*
19+
* @package WebDriver
20+
*/
21+
final class InsecureCertificate extends BaseException
22+
{
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/**
4+
* @copyright 2019 Anthon Pang
5+
* @license Apache-2.0
6+
*
7+
* @package WebDriver
8+
*
9+
* @author Anthon Pang <apang@softwaredevelopment.ca>
10+
*/
11+
12+
namespace WebDriver\Exception;
13+
14+
use WebDriver\Exception as BaseException;
15+
16+
/**
17+
* WebDriver\Exception\InvalidArgument class
18+
*
19+
* @package WebDriver
20+
*/
21+
final class InvalidArgument extends BaseException
22+
{
23+
}

0 commit comments

Comments
 (0)