Skip to content

Commit a300b45

Browse files
committed
[js] For consistency, InvalidSessionIdError -> NoSuchSessionError
1 parent dd2da4b commit a300b45

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

javascript/node/selenium-webdriver/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
driver.findElements(By.css('.foo')).then(found => !!found.length);
1313
* Added support for W3C-spec compliant servers.
14+
* For consistent naming, deprecating `error.InvalidSessionIdError` in favor of
15+
`error.NoSuchSessionError`.
1416

1517
### Changes for W3C WebDriver Spec Compliance
1618

javascript/node/selenium-webdriver/error.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,20 @@ class InvalidSelectorError extends WebDriverError {
160160

161161

162162
/**
163-
* Occurs if the given session id is not in the list of active sessions, meaning
164-
* the session either does not exist or that it’s not active.
163+
* Occurs when a command is directed to a session that does not exist.
165164
*/
166-
class InvalidSessionIdError extends WebDriverError {
165+
class NoSuchSessionError extends WebDriverError {
166+
/** @param {string=} opt_error the error message, if any. */
167+
constructor(opt_error) {
168+
super(opt_error);
169+
}
170+
}
171+
172+
173+
/**
174+
* @deprecated Use {@link NoSuchSessionError} instead.
175+
*/
176+
class InvalidSessionIdError extends NoSuchSessionError {
167177
/** @param {string=} opt_error the error message, if any. */
168178
constructor(opt_error) {
169179
super(opt_error);
@@ -521,7 +531,7 @@ const ERROR_CODE_TO_TYPE = new Map([
521531
['invalid element coordinates', InvalidElementCoordinatesError],
522532
['invalid element state', InvalidElementStateError],
523533
['invalid selector', InvalidSelectorError],
524-
['invalid session id', InvalidSessionIdError],
534+
['invalid session id', NoSuchSessionError],
525535
['javascript error', JavascriptError],
526536
['move target out of bounds', MoveTargetOutOfBoundsError],
527537
['no such alert', NoSuchAlertError],
@@ -630,6 +640,7 @@ exports.MoveTargetOutOfBoundsError = MoveTargetOutOfBoundsError;
630640
exports.NoSuchAlertError = NoSuchAlertError;
631641
exports.NoSuchElementError = NoSuchElementError;
632642
exports.NoSuchFrameError = NoSuchFrameError;
643+
exports.NoSuchSessionError = NoSuchSessionError;
633644
exports.NoSuchWindowError = NoSuchWindowError;
634645
exports.ScriptTimeoutError = ScriptTimeoutError;
635646
exports.SessionNotCreatedError = SessionNotCreatedError;

javascript/node/selenium-webdriver/lib/webdriver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ class WebDriver {
356356

357357
function checkHasNotQuit() {
358358
if (!self.session_) {
359-
throw new error.UnsupportedOperationError(
359+
throw new error.NoSuchSessionError(
360360
'This driver instance does not have a valid session ID ' +
361361
'(did you call WebDriver.quit()?) and may no longer be ' +
362362
'used.');

javascript/node/selenium-webdriver/test/error_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ describe('error', function() {
4646
test('invalid element coordinates', error.InvalidElementCoordinatesError);
4747
test('invalid element state', error.InvalidElementStateError);
4848
test('invalid selector', error.InvalidSelectorError);
49-
test('invalid session id', error.InvalidSessionIdError);
49+
test('invalid session id', error.NoSuchSessionError);
5050
test('javascript error', error.JavascriptError);
5151
test('move target out of bounds', error.MoveTargetOutOfBoundsError);
5252
test('no such alert', error.NoSuchAlertError);
@@ -119,7 +119,7 @@ describe('error', function() {
119119
test('invalid element coordinates', error.InvalidElementCoordinatesError);
120120
test('invalid element state', error.InvalidElementStateError);
121121
test('invalid selector', error.InvalidSelectorError);
122-
test('invalid session id', error.InvalidSessionIdError);
122+
test('invalid session id', error.NoSuchSessionError);
123123
test('javascript error', error.JavascriptError);
124124
test('move target out of bounds', error.MoveTargetOutOfBoundsError);
125125
test('no such alert', error.NoSuchAlertError);
@@ -243,7 +243,7 @@ describe('error', function() {
243243
check(error.InvalidElementCoordinatesError, 'INVALID_ELEMENT_COORDINATES');
244244
check(error.InvalidElementStateError, 'INVALID_ELEMENT_STATE');
245245
check(error.InvalidSelectorError, 'INVALID_SELECTOR_ERROR');
246-
check(error.InvalidSessionIdError, 'UNKNOWN_ERROR');
246+
check(error.NoSuchSessionError, 'UNKNOWN_ERROR');
247247
check(error.JavascriptError, 'JAVASCRIPT_ERROR');
248248
check(error.MoveTargetOutOfBoundsError, 'MOVE_TARGET_OUT_OF_BOUNDS');
249249
check(error.NoSuchAlertError, 'NO_SUCH_ALERT');

javascript/node/selenium-webdriver/test/lib/webdriver_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ describe('WebDriver', function() {
485485
driver.get('http://www.google.com');
486486
return waitForAbort().
487487
then(expectedError(
488-
error.UnsupportedOperationError,
488+
error.NoSuchSessionError,
489489
'This driver instance does not have a valid session ID ' +
490490
'(did you call WebDriver.quit()?) and may no longer be used.'));
491491
});

0 commit comments

Comments
 (0)