How to use the appium-base-driver.isErrorType function in appium-base-driver

To help you get started, we’ve selected a few appium-base-driver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appium / appium-xcuitest-driver / lib / commands / context.js View on Github external
commands.setWindow = async function setWindow (name, skipReadyCheck) {
  try {
    await this.setContext(name, _.noop, skipReadyCheck);
  } catch (err) {
    // translate the error in terms of windows
    throw isErrorType(err, errors.NoSuchContextError)
      ? new errors.NoSuchWindowError()
      : err;
  }
};
github appium / appium-android-driver / lib / commands / find.js View on Github external
let doFind = async () => {
    try {
      element = await this.doFindElementOrEls(params);
    } catch (err) {

      // if the error that comes back is from a proxied request, we need to
      // unwrap it to its actual protocol error first
      if (isErrorType(err, errors.ProxyRequestError)) {
        err = err.getActualError(); // eslint-disable-line no-ex-assign
      }

      // now we have to inspect the error to determine if it is a no such
      // element error, based on the shape of the error object from
      // appium-base-driver
      if (isErrorType(err, errors.NoSuchElementError)) {
        // we are fine with this, just indicate a retry
        return false;
      }
      throw err;
    }

    // we want to return false if we want to potentially try again
    return !_.isEmpty(element);
  };
github appium / appium-android-driver / lib / commands / find.js View on Github external
let doFind = async () => {
    try {
      element = await this.doFindElementOrEls(params);
    } catch (err) {

      // if the error that comes back is from a proxied request, we need to
      // unwrap it to its actual protocol error first
      if (isErrorType(err, errors.ProxyRequestError)) {
        err = err.getActualError(); // eslint-disable-line no-ex-assign
      }

      // now we have to inspect the error to determine if it is a no such
      // element error, based on the shape of the error object from
      // appium-base-driver
      if (isErrorType(err, errors.NoSuchElementError)) {
        // we are fine with this, just indicate a retry
        return false;
      }
      throw err;
    }

    // we want to return false if we want to potentially try again
    return !_.isEmpty(element);
  };
github Samsung / appium-tizen-driver / lib / commands / touch.js View on Github external
commands.performGesture = async function (gesture) {
  try {
    return await this.doTouchAction(gesture.action, gesture.options || {});
  } catch (e) {
    // sometime the element is not available when releasing, retry without it
    if (isErrorType(e, errors.NoSuchElementError) && gesture.action === 'release' &&
      gesture.options.element) {
      delete gesture.options.element;
      log.debug(`retrying release without element opts: ${gesture.options}.`);
      return await this.doTouchAction(gesture.action, gesture.options || {});
    }
    throw e;
  }
};
github appium / appium-android-driver / lib / commands / touch.js View on Github external
helpers.performGesture = async function performGesture (gesture) {
  try {
    return await this.doTouchAction(gesture.action, gesture.options || {});
  } catch (e) {
    // sometime the element is not available when releasing, retry without it
    if (isErrorType(e, errors.NoSuchElementError) && gesture.action === 'release' &&
        gesture.options.element) {
      delete gesture.options.element;
      log.debug(`retrying release without element opts: ${gesture.options}.`);
      return await this.doTouchAction(gesture.action, gesture.options || {});
    }
    throw e;
  }
};
github appium / appium-xcuitest-driver / lib / commands / alert.js View on Github external
alert.setText = async (value) => {
    try {
      let textView = await this.findNativeElementOrElements('class name', 'XCUIElementTypeTextField', false, util.unwrapElement(alert));
      await this.proxyCommand(`/element/${util.unwrapElement(textView)}/value `, 'POST', {value});
    } catch (err) {
      if (isErrorType(err, errors.NoSuchElementError)) {
        throw new Error('Tried to set text of an alert that was not a prompt');
      }
      throw err;
    }
  };
github Samsung / appium-tizen-driver / lib / commands / find.js View on Github external
let doFind = async () => {
    try {
      element = await this.doFindElementOrEls(params);
    } catch (err) {
      if (isErrorType(err, errors.NoSuchElementError)) {
        return false;
      }
      throw err;
    }

    return !_.isEmpty(element);
  };