How to use the appium-base-driver.errors.InvalidSelectorError 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 / find.js View on Github external
}

  if (strategy === 'xpath' && MAGIC_FIRST_VIS_CHILD_SEL.test(selector)) {
    if (mult) {
      throw new Error('Cannot get multiple first children');
    }
    return await this.getFirstVisibleChild(context);
  }

  // previously getSelectorForStrategy
  if (strategy === 'class name' && selector.indexOf('UIA') !== 0) {
    throw new errors.InvalidSelectorError(
      `The class name selector must use full UIA class names. Try 'UIA${selector}' instead.`);
  }

  if (!selector) new errors.InvalidSelectorError('Missing selector'); // eslint-disable-line curly

  let createGetElementCommand = function (strategy, selector, mult, context) {
    let ext = mult ? 's' : '';
    let command = '';
    context = !context ? context : `, '${context}'` ;
    switch (strategy) {
      case 'name':
        command = `au.getElement${ext}ByName('${selector}'${context})`;
        break;
      case 'accessibility id':
        command = `au.getElement${ext}ByAccessibilityId('${selector}'${context})`;
        break;
      case 'id':
        command = `au.getElement${ext}ById('${selector}')`;
        break;
      case '-ios uiautomation':
github appium / appium-ios-driver / lib / commands / find.js View on Github external
}

  if (strategy === 'xpath' && MAGIC_SCROLLABLE_SEL.test(selector)) {
    return await this.findScrollableElOrEls(mult, context);
  }

  if (strategy === 'xpath' && MAGIC_FIRST_VIS_CHILD_SEL.test(selector)) {
    if (mult) {
      throw new Error('Cannot get multiple first children');
    }
    return await this.getFirstVisibleChild(context);
  }

  // previously getSelectorForStrategy
  if (strategy === 'class name' && selector.indexOf('UIA') !== 0) {
    throw new errors.InvalidSelectorError(
      `The class name selector must use full UIA class names. Try 'UIA${selector}' instead.`);
  }

  if (!selector) new errors.InvalidSelectorError('Missing selector'); // eslint-disable-line curly

  let createGetElementCommand = function (strategy, selector, mult, context) {
    let ext = mult ? 's' : '';
    let command = '';
    context = !context ? context : `, '${context}'` ;
    switch (strategy) {
      case 'name':
        command = `au.getElement${ext}ByName('${selector}'${context})`;
        break;
      case 'accessibility id':
        command = `au.getElement${ext}ByAccessibilityId('${selector}'${context})`;
        break;