Skip to content

Commit 2896e5e

Browse files
committed
Fix #87 W3C error strings
1 parent df59762 commit 2896e5e

11 files changed

+361
-6
lines changed

lib/WebDriver/Exception.php

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,35 @@ abstract class Exception extends \Exception
122122
self::UNEXPECTED_PARAMETERS => array('UnexpectedParameters', 'This command does not expect this number of parameters.'),
123123
self::INVALID_REQUEST => array('InvalidRequest', 'This command does not support this HTTP request method.'),
124124
self::UNKNOWN_LOCATOR_STRATEGY => array('UnknownLocatorStrategy', 'This locator strategy is not supported.'),
125+
126+
// @link https://w3c.github.io/webdriver/#errors
127+
'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.'),
128+
'element not interactable' => array('ElementNotInteractable', 'A command could not be completed because the element is not pointer- or keyboard interactable.'),
129+
'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.'),
130+
'invalid argument' => array('InvalidArgument', 'The arguments passed to a command are either invalid or malformed.'),
131+
'invalid cookie domain' => array('InvalidCookieDomain', 'An illegal attempt was made to set a cookie under a different domain than the current page.'),
132+
'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.'),
133+
'invalid selector' => array('InvalidSelector', 'Argument was an invalid selector.'),
134+
'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.'),
135+
'javascript error' => array('JavaScriptError', 'An error occurred while executing JavaScript supplied by the user.'),
136+
'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.'),
137+
'no such alert' => array('NoSuchAlert', 'An attempt was made to operate on a modal dialog when one was not open.'),
138+
'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.'),
139+
'no such element' => array('NoSuchElement', 'An element could not be located on the page using the given search parameters.'),
140+
'no such frame' => array('NoSuchFrame', 'A command to switch to a frame could not be satisfied because the frame could not be found.'),
141+
'no such window' => array('NoSuchWindow', 'A command to switch to a window could not be satisfied because the window could not be found.'),
142+
'script timeout' => array('ScriptTimeout', 'A script did not complete before its timeout expired.'),
143+
'script timeout error' => array('ScriptTimeout', 'A script did not complete before its timeout expired.'),
144+
'session not created' => array('SessionNotCreated', 'A new session could not be created.'),
145+
'stale element reference' => array('StaleElementReference', 'A command failed because the referenced element is no longer attached to the DOM.'),
146+
'timeout' => array('Timeout', 'An operation did not complete before its timeout expired.'),
147+
'unable to set cookie' => array('UnableToSetCookie', 'A command to set a cookie\'s value could not be satisfied.'),
148+
'unable to capture screen' => array('UnableToCaptureScreen', 'A screen capture was made impossible.'),
149+
'unexpected alert open' => array('UnexpectedAlertOpen', 'A modal dialog was open, blocking this operation.'),
150+
'unknown command' => array('UnknownCommand', 'A command could not be executed because the remote end is not aware of it.'),
151+
'unknown error' => array('UnknownError', 'An unknown error occurred in the remote end while processing the command.'),
152+
'unknown method' => array('UnknownMethod', 'The requested command matched a known URL but did not match an method for that URL.'),
153+
'unsupported operation' => array('UnsupportedOperation', 'Indicates that a command that should have executed properly cannot be supported for some reason.'),
125154
);
126155

127156
/**
@@ -136,12 +165,8 @@ abstract class Exception extends \Exception
136165
public static function factory($code, $message = null, $previousException = null)
137166
{
138167
// unknown error
139-
if (!isset(self::$errs[$code])) {
140-
if (trim($message) === '') {
141-
$message = 'Unknown Error';
142-
}
143-
144-
return new \Exception($message, $code, $previousException);
168+
if (! isset(self::$errs[$code])) {
169+
$code = self::UNKNOWN_ERROR;
145170
}
146171

147172
$errorDefinition = self::$errs[$code];
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\ElementClickIntercepted class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class ElementClickIntercepted extends BaseException
32+
{
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\ElementNotInteractable class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class ElementNotInteractable extends BaseException
32+
{
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\InsecureCertificate class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class InsecureCertificate extends BaseException
32+
{
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\InvalidArgument class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class InvalidArgument extends BaseException
32+
{
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\InvalidSessionID class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class InvalidSessionID extends BaseException
32+
{
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\NoSuchAlert class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class NoSuchAlert extends BaseException
32+
{
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\NoSuchCookie class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class NoSuchCookie extends BaseException
32+
{
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\UnableToCaptureScreen class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class UnableToCaptureScreen extends BaseException
32+
{
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright 2019-2019 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.
16+
*
17+
* @package WebDriver
18+
*
19+
* @author Anthon Pang <[email protected]>
20+
*/
21+
22+
namespace WebDriver\Exception;
23+
24+
use WebDriver\Exception as BaseException;
25+
26+
/**
27+
* WebDriver\Exception\UnknownMethod class
28+
*
29+
* @package WebDriver
30+
*/
31+
final class UnknownMethod extends BaseException
32+
{
33+
}

0 commit comments

Comments
 (0)