How to use the appium-base-driver.errors.UnknownError 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-ios-driver / lib / commands / web.js View on Github external
helpers.parseExecuteResponse = function parseExecuteResponse (res) {
  if (_.isNull(res) || _.isUndefined(res)) return null; // eslint-disable-line curly

  let wdElement = null;
  if (!_.isArray(res)) {
    if (helpers.hasElementId(res)) {
      wdElement = this.parseElementResponse(res);
      if (wdElement === null) {
        throw new errors.UnknownError(`Error converting element ID atom for using in WD: '${helpers.getElementId(res)}'`);
      }
      res = wdElement;
    }
  } else {
    // value is an array, so go through and convert each
    let args = [];
    for (let arg of res) {
      wdElement = arg;
      if (helpers.hasElementId(arg)) {
        wdElement = this.parseElementResponse(arg);
        if (wdElement === null) {
          throw new errors.UnknownError(`Error converting element ID atom for using in WD: '${helpers.getElementId(arg)}'`);
        }
        args.push(wdElement);
      } else {
        args.push(arg);
github appium / appium-ios-driver / lib / commands / web.js View on Github external
helpers.convertElementsForAtoms = function convertElementsForAtoms (args = []) {
  const resultArgs = [];
  for (const arg of args) {
    if (helpers.hasElementId(arg)) {
      // Get the element key from W3C or MJSONWP key
      const elementId = helpers.getElementId(arg);
      const atomsElement = this.getAtomsElement(elementId);
      if (atomsElement === null) {
        throw new errors.UnknownError(`Error converting element ID for using in WD atoms: '${elementId}'`);
      }
      resultArgs.push(atomsElement);
    } else if (_.isArray(arg)) {
      resultArgs.push(this.convertElementsForAtoms(arg));
    } else {
      resultArgs.push(arg);
    }
  }
  return resultArgs;
};
github appium / appium-xcuitest-driver / lib / commands / general.js View on Github external
commands.keys = async function keys (keys) {
  if (!this.isWebContext()) {
    throw new errors.UnknownError('Command should be proxied to WDA');
  }
  let el = util.unwrapElement(await this.active());
  if (_.isEmpty(el)) {
    throw new errors.NoSuchElementError();
  }
  await this.setValue(keys, el);
};
github appium / appium-xcuitest-driver / lib / commands / element.js View on Github external
commands.getAttribute = async function getAttribute (attribute, el) {
  el = util.unwrapElement(el);
  if (!this.isWebContext()) {
    return await this.getNativeAttribute(attribute, el);
  }
  const atomsElement = this.getAtomsElement(el);
  if (_.isNull(atomsElement)) {
    throw new errors.UnknownError(`Error converting element ID for using in WD atoms: '${el}`);
  }
  return await this.executeAtom('get_attribute_value', [atomsElement, attribute]);
};
github appium / appium-xcuitest-driver / lib / commands / gesture.js View on Github external
commands.mobileShake = async function mobileShake () {
  if (!this.isSimulator()) {
    throw new errors.UnknownError('Shake is not supported on real devices');
  }
  await this.opts.device.shake();
};
github appium / appium-xcuitest-driver / lib / commands / element.js View on Github external
commands.getSize = async function getSize (el) {
  el = util.unwrapElement(el);
  if (this.isWebContext()) {
    let atomsElement = this.getAtomsElement(el);
    if (atomsElement === null) {
      throw new errors.UnknownError(`Error converting element ID for using in WD atoms: '${el}'`);
    }
    return await this.executeAtom('get_size', [atomsElement]);
  }

  const rect = await this.getElementRect(el);
  return {width: rect.width, height: rect.height};
};
github appium / appium-ios-driver / lib / driver.js View on Github external
logger.debug('fullReset requested. Forcing app install.');
        } else {
          logger.debug('fullReset not requested. No need to install.');
          return;
        }
      } else {
        logger.debug('App is not installed. Will try to install.');
      }

      if (this.opts.ipa && this.opts.bundleId) {
        await this.installIpa();
        logger.debug('App installed.');
      } else if (this.opts.ipa) {
        let msg = 'You specified a UDID and ipa but did not include the bundle id';
        logger.warn(msg);
        throw new errors.UnknownError(msg);
      } else if (this.opts.app) {
        await this.realDevice.install(this.opts.app);
        logger.debug('App installed.');
      } else {
        logger.debug('Real device specified but no ipa or app path, assuming bundle ID is ' +
                     'on device');
      }
    } else {
      logger.debug('No device id or app, not installing to real device.');
    }
  }
github appium / appium-ios-driver / lib / commands / gesture.js View on Github external
commands.clickCurrent = async function clickCurrent (/*button*/) {
  if (this.isWebContext()) {
    if (_.isNull(this.curWebCoords)) {
      throw new errors.UnknownError('Cannot call click() before calling moveTo() to set coords');
    }
    await this.clickWebCoords();
  } else {
    if (this.curCoords === null) {
      throw new errors.UnknownError('Cannot call click() before calling moveTo() to set coords');
    }
    await this.clickCoords(this.curCoords);
  }
};
github appium / appium-ios-driver / lib / commands / web.js View on Github external
helpers.useAtomsElement = function useAtomsElement (el) {
  if (parseInt(el, 10) < ELEMENT_OFFSET) {
    logger.debug(`Element with id '${el}' passed in for use with ` +
                 `atoms, but it's out of our internal scope. Adding ${ELEMENT_OFFSET}.`);
    el = (parseInt(el, 10) + ELEMENT_OFFSET).toString();
  }
  let atomsElement = this.getAtomsElement(el);
  if (atomsElement === null) {
    throw new errors.UnknownError(`Error converting element ID for using in WD atoms: '${el}'`);
  }
  return atomsElement;
};