Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Commit

Permalink
[js] For consistency, InvalidSessionIdError -> NoSuchSessionError
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed Feb 22, 2016
1 parent dd2da4b commit a300b45
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
2 changes: 2 additions & 0 deletions javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

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

### Changes for W3C WebDriver Spec Compliance

Expand Down
19 changes: 15 additions & 4 deletions javascript/node/selenium-webdriver/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,20 @@ class InvalidSelectorError extends WebDriverError {


/**
* 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.
* Occurs when a command is directed to a session that does not exist.
*/
class InvalidSessionIdError extends WebDriverError {
class NoSuchSessionError extends WebDriverError {
/** @param {string=} opt_error the error message, if any. */
constructor(opt_error) {
super(opt_error);
}
}


/**
* @deprecated Use {@link NoSuchSessionError} instead.
*/
class InvalidSessionIdError extends NoSuchSessionError {
/** @param {string=} opt_error the error message, if any. */
constructor(opt_error) {
super(opt_error);
Expand Down Expand Up @@ -521,7 +531,7 @@ const ERROR_CODE_TO_TYPE = new Map([
['invalid element coordinates', InvalidElementCoordinatesError],
['invalid element state', InvalidElementStateError],
['invalid selector', InvalidSelectorError],
['invalid session id', InvalidSessionIdError],
['invalid session id', NoSuchSessionError],
['javascript error', JavascriptError],
['move target out of bounds', MoveTargetOutOfBoundsError],
['no such alert', NoSuchAlertError],
Expand Down Expand Up @@ -630,6 +640,7 @@ exports.MoveTargetOutOfBoundsError = MoveTargetOutOfBoundsError;
exports.NoSuchAlertError = NoSuchAlertError;
exports.NoSuchElementError = NoSuchElementError;
exports.NoSuchFrameError = NoSuchFrameError;
exports.NoSuchSessionError = NoSuchSessionError;
exports.NoSuchWindowError = NoSuchWindowError;
exports.ScriptTimeoutError = ScriptTimeoutError;
exports.SessionNotCreatedError = SessionNotCreatedError;
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/lib/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class WebDriver {

function checkHasNotQuit() {
if (!self.session_) {
throw new error.UnsupportedOperationError(
throw new error.NoSuchSessionError(
'This driver instance does not have a valid session ID ' +
'(did you call WebDriver.quit()?) and may no longer be ' +
'used.');
Expand Down
6 changes: 3 additions & 3 deletions javascript/node/selenium-webdriver/test/error_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('error', function() {
test('invalid element coordinates', error.InvalidElementCoordinatesError);
test('invalid element state', error.InvalidElementStateError);
test('invalid selector', error.InvalidSelectorError);
test('invalid session id', error.InvalidSessionIdError);
test('invalid session id', error.NoSuchSessionError);
test('javascript error', error.JavascriptError);
test('move target out of bounds', error.MoveTargetOutOfBoundsError);
test('no such alert', error.NoSuchAlertError);
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('error', function() {
test('invalid element coordinates', error.InvalidElementCoordinatesError);
test('invalid element state', error.InvalidElementStateError);
test('invalid selector', error.InvalidSelectorError);
test('invalid session id', error.InvalidSessionIdError);
test('invalid session id', error.NoSuchSessionError);
test('javascript error', error.JavascriptError);
test('move target out of bounds', error.MoveTargetOutOfBoundsError);
test('no such alert', error.NoSuchAlertError);
Expand Down Expand Up @@ -243,7 +243,7 @@ describe('error', function() {
check(error.InvalidElementCoordinatesError, 'INVALID_ELEMENT_COORDINATES');
check(error.InvalidElementStateError, 'INVALID_ELEMENT_STATE');
check(error.InvalidSelectorError, 'INVALID_SELECTOR_ERROR');
check(error.InvalidSessionIdError, 'UNKNOWN_ERROR');
check(error.NoSuchSessionError, 'UNKNOWN_ERROR');
check(error.JavascriptError, 'JAVASCRIPT_ERROR');
check(error.MoveTargetOutOfBoundsError, 'MOVE_TARGET_OUT_OF_BOUNDS');
check(error.NoSuchAlertError, 'NO_SUCH_ALERT');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ describe('WebDriver', function() {
driver.get('http://www.google.com');
return waitForAbort().
then(expectedError(
error.UnsupportedOperationError,
error.NoSuchSessionError,
'This driver instance does not have a valid session ID ' +
'(did you call WebDriver.quit()?) and may no longer be used.'));
});
Expand Down

0 comments on commit a300b45

Please sign in to comment.