Dart API ReferencewebdriverWebDriverError

WebDriverError class

class WebDriverError {
  static List _errorTypes = null;
  static List _errorDetails = null;
  int statusCode;
  String type;
  String message;
  String details;
  String results;

  WebDriverError(this.statusCode, this.message, [this.results = '']) {
    /** These correspond to WebDrive exception types. */
    if (_errorTypes == null) {
      _errorTypes = [
        null,
        'IndexOutOfBounds',
        'NoCollection',
        'NoString',
        'NoStringLength',
        'NoStringWrapper',
        'NoSuchDriver',
        'NoSuchElement',
        'NoSuchFrame',
        'UnknownCommand',
        'ObsoleteElement',
        'ElementNotDisplayed',
        'InvalidElementState',
        'Unhandled',
        'Expected',
        'ElementNotSelectable',
        'NoSuchDocument',
        'UnexpectedJavascript',
        'NoScriptResult',
        'XPathLookup',
        'NoSuchCollection',
        'TimeOut',
        'NullPointer',
        'NoSuchWindow',
        'InvalidCookieDomain',
        'UnableToSetCookie',
        'UnexpectedAlertOpen',
        'NoAlertOpen',
        'ScriptTimeout',
        'InvalidElementCoordinates',
        'IMENotAvailable',
        'IMEEngineActivationFailed',
        'InvalidSelector',
        'SessionNotCreatedException',
        'MoveTargetOutOfBounds'
      ];
      // Explanations of the eror types. In thoses cases where the
      // explanation is the same as the type (e.g. NoCollection), that is an
      // error type used by an old version of the IE driver and is deprecated.
      _errorDetails = [
        null,
        'IndexOutOfBounds',
        'NoCollection',
        'NoString',
        'NoStringLength',
        'NoStringWrapper',
        'NoSuchDriver',
        'An element could not be located on the page using the given '
            'search parameters.',
        'A request to switch to a frame could not be satisfied because the '
            'frame could not be found.',
        'The requested resource could not be found, or a request was '
            'received using an HTTP method that is not supported by the '
            'mapped resource.',
        'An element command failed because the referenced element is no '
            'longer attached to the DOM.',
        'An element command could not be completed because the element '
            'is not visible on the page.',
        'An element command could not be completed because the element is in '
            'an invalid state (e.g. attempting to click a disabled element).',
        'An unknown server-side error occurred while processing the command.',
        'Expected',
        'An attempt was made to select an element that cannot be selected.',
        'NoSuchDocument',
        'An error occurred while executing user supplied JavaScript.',
        'NoScriptResult',
        'An error occurred while searching for an element by XPath.',
        'NoSuchCollection',
        'An operation did not complete before its timeout expired.',
        'NullPointer',
        'A request to switch to a different window could not be satisfied '
            'because the window could not be found.',
        'An illegal attempt was made to set a cookie under a different '
            'domain than the current page.',
        'A request to set a cookie\'s value could not be satisfied.',
        'A modal dialog was open, blocking this operation.',
        'An attempt was made to operate on a modal dialog when one was '
            'not open.',
        'A script did not complete before its timeout expired.',
        'The coordinates provided to an interactions operation are invalid.',
        'IME was not available.',
        'An IME engine could not be started.',
        'Argument was an invalid selector (e.g. XPath/CSS).',
        'A new session could not be created.',
        'Target provided for a move action is out of bounds.'
      ];
    }
    if (statusCode < 0 || statusCode > 32) {
      type = 'External';
      details = '';
    } else {
      type = _errorTypes[statusCode];
      details = _errorDetails[statusCode];
    }
  }

  String toString() {
    return '$statusCode $type: $message $results\n$details';
  }
}

Constructors

new WebDriverError(int statusCode, String message, [String results = '']) #

WebDriverError(this.statusCode, this.message, [this.results = '']) {
  /** These correspond to WebDrive exception types. */
  if (_errorTypes == null) {
    _errorTypes = [
      null,
      'IndexOutOfBounds',
      'NoCollection',
      'NoString',
      'NoStringLength',
      'NoStringWrapper',
      'NoSuchDriver',
      'NoSuchElement',
      'NoSuchFrame',
      'UnknownCommand',
      'ObsoleteElement',
      'ElementNotDisplayed',
      'InvalidElementState',
      'Unhandled',
      'Expected',
      'ElementNotSelectable',
      'NoSuchDocument',
      'UnexpectedJavascript',
      'NoScriptResult',
      'XPathLookup',
      'NoSuchCollection',
      'TimeOut',
      'NullPointer',
      'NoSuchWindow',
      'InvalidCookieDomain',
      'UnableToSetCookie',
      'UnexpectedAlertOpen',
      'NoAlertOpen',
      'ScriptTimeout',
      'InvalidElementCoordinates',
      'IMENotAvailable',
      'IMEEngineActivationFailed',
      'InvalidSelector',
      'SessionNotCreatedException',
      'MoveTargetOutOfBounds'
    ];
    // Explanations of the eror types. In thoses cases where the
    // explanation is the same as the type (e.g. NoCollection), that is an
    // error type used by an old version of the IE driver and is deprecated.
    _errorDetails = [
      null,
      'IndexOutOfBounds',
      'NoCollection',
      'NoString',
      'NoStringLength',
      'NoStringWrapper',
      'NoSuchDriver',
      'An element could not be located on the page using the given '
          'search parameters.',
      'A request to switch to a frame could not be satisfied because the '
          'frame could not be found.',
      'The requested resource could not be found, or a request was '
          'received using an HTTP method that is not supported by the '
          'mapped resource.',
      'An element command failed because the referenced element is no '
          'longer attached to the DOM.',
      'An element command could not be completed because the element '
          'is not visible on the page.',
      'An element command could not be completed because the element is in '
          'an invalid state (e.g. attempting to click a disabled element).',
      'An unknown server-side error occurred while processing the command.',
      'Expected',
      'An attempt was made to select an element that cannot be selected.',
      'NoSuchDocument',
      'An error occurred while executing user supplied JavaScript.',
      'NoScriptResult',
      'An error occurred while searching for an element by XPath.',
      'NoSuchCollection',
      'An operation did not complete before its timeout expired.',
      'NullPointer',
      'A request to switch to a different window could not be satisfied '
          'because the window could not be found.',
      'An illegal attempt was made to set a cookie under a different '
          'domain than the current page.',
      'A request to set a cookie\'s value could not be satisfied.',
      'A modal dialog was open, blocking this operation.',
      'An attempt was made to operate on a modal dialog when one was '
          'not open.',
      'A script did not complete before its timeout expired.',
      'The coordinates provided to an interactions operation are invalid.',
      'IME was not available.',
      'An IME engine could not be started.',
      'Argument was an invalid selector (e.g. XPath/CSS).',
      'A new session could not be created.',
      'Target provided for a move action is out of bounds.'
    ];
  }
  if (statusCode < 0 || statusCode > 32) {
    type = 'External';
    details = '';
  } else {
    type = _errorTypes[statusCode];
    details = _errorDetails[statusCode];
  }
}

Properties

String details #

String details;

String message #

String message;

String results #

String results;

int statusCode #

int statusCode;

String type #

String type;

Methods

String toString() #

Returns a string representation of this object.

docs inherited from Object
String toString() {
  return '$statusCode $type: $message $results\n$details';
}