How to use the appium-base-driver.PROTOCOLS.W3C 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-chromedriver / lib / chromedriver.js View on Github external
syncProtocol (cdVersion = null) {
    const coercedVersion = semver.coerce(cdVersion);
    if (!coercedVersion || coercedVersion.major < MIN_CD_VERSION_WITH_W3C_SUPPORT) {
      log.debug(`Chromedriver v. ${cdVersion} does not fully support ${PROTOCOLS.W3C} protocol. ` +
        `Defaulting to ${PROTOCOLS.MJSONWP}`);
      return;
    }
    const chromeOptions = getCapValue(this.capabilities, 'chromeOptions', {});
    if (chromeOptions.w3c === false) {
      log.info(`Chromedriver v. ${cdVersion} supports ${PROTOCOLS.W3C} protocol, ` +
        `but ${PROTOCOLS.MJSONWP} one has been explicitly requested`);
      return;
    }
    this.desiredProtocol = PROTOCOLS.W3C;
    // given caps might not be properly prefixed
    // so we try to fix them in order to properly init
    // the new W3C session
    this.capabilities = toW3cCapNames(this.capabilities);
  }
github appium / appium-chromedriver / lib / chromedriver.js View on Github external
syncProtocol (cdVersion = null) {
    const coercedVersion = semver.coerce(cdVersion);
    if (!coercedVersion || coercedVersion.major < MIN_CD_VERSION_WITH_W3C_SUPPORT) {
      log.debug(`Chromedriver v. ${cdVersion} does not fully support ${PROTOCOLS.W3C} protocol. ` +
        `Defaulting to ${PROTOCOLS.MJSONWP}`);
      return;
    }
    const chromeOptions = getCapValue(this.capabilities, 'chromeOptions', {});
    if (chromeOptions.w3c === false) {
      log.info(`Chromedriver v. ${cdVersion} supports ${PROTOCOLS.W3C} protocol, ` +
        `but ${PROTOCOLS.MJSONWP} one has been explicitly requested`);
      return;
    }
    this.desiredProtocol = PROTOCOLS.W3C;
    // given caps might not be properly prefixed
    // so we try to fix them in order to properly init
    // the new W3C session
    this.capabilities = toW3cCapNames(this.capabilities);
  }
github appium / appium-chromedriver / lib / chromedriver.js View on Github external
async startSession () {
    const sessionCaps = this.desiredProtocol === PROTOCOLS.W3C
      ? {capabilities: {alwaysMatch: this.capabilities}}
      : {desiredCapabilities: this.capabilities};
    log.info(`Starting ${this.desiredProtocol} Chromedriver session with capabilities: ` +
      JSON.stringify(sessionCaps, null, 2));
    // retry session start 4 times, sometimes this fails due to adb
    await retryInterval(4, 200, async () => {
      try {
        await this.jwproxy.command('/session', 'POST', sessionCaps);
      } catch (err) {
        log.warn(`Failed to start Chromedriver session: ${err.message}`);
        throw err;
      }
    });
    this.changeState(Chromedriver.STATE_ONLINE);
  }
github appium / appium / lib / utils.js View on Github external
function parseCapsForInnerDriver (jsonwpCapabilities, w3cCapabilities, constraints = {}, defaultCapabilities = {}) {
  // Check if the caller sent JSONWP caps, W3C caps, or both
  const hasW3CCaps = _.isPlainObject(w3cCapabilities) &&
    (_.has(w3cCapabilities, 'alwaysMatch') || _.has(w3cCapabilities, 'firstMatch'));
  const hasJSONWPCaps = _.isPlainObject(jsonwpCapabilities);
  let protocol = null;
  let desiredCaps = {};
  let processedW3CCapabilities = null;
  let processedJsonwpCapabilities = null;

  if (!hasJSONWPCaps && !hasW3CCaps) {
    return {
      protocol: PROTOCOLS.W3C,
      error: new Error('Either JSONWP or W3C capabilities should be provided'),
    };
  }

  const {W3C, MJSONWP} = PROTOCOLS;

  // Make sure we don't mutate the original arguments
  jsonwpCapabilities = _.cloneDeep(jsonwpCapabilities);
  w3cCapabilities = _.cloneDeep(w3cCapabilities);
  defaultCapabilities = _.cloneDeep(defaultCapabilities);

  if (!_.isEmpty(defaultCapabilities)) {
    if (hasW3CCaps) {
      const {firstMatch = [], alwaysMatch = {}} = w3cCapabilities;
      for (const [defaultCapKey, defaultCapValue] of _.toPairs(defaultCapabilities)) {
        let isCapAlreadySet = false;
github appium / appium-chromedriver / lib / chromedriver.js View on Github external
syncProtocol (cdVersion = null) {
    const coercedVersion = semver.coerce(cdVersion);
    if (!coercedVersion || coercedVersion.major < MIN_CD_VERSION_WITH_W3C_SUPPORT) {
      log.debug(`Chromedriver v. ${cdVersion} does not fully support ${PROTOCOLS.W3C} protocol. ` +
        `Defaulting to ${PROTOCOLS.MJSONWP}`);
      return;
    }
    const chromeOptions = getCapValue(this.capabilities, 'chromeOptions', {});
    if (chromeOptions.w3c === false) {
      log.info(`Chromedriver v. ${cdVersion} supports ${PROTOCOLS.W3C} protocol, ` +
        `but ${PROTOCOLS.MJSONWP} one has been explicitly requested`);
      return;
    }
    this.desiredProtocol = PROTOCOLS.W3C;
    // given caps might not be properly prefixed
    // so we try to fix them in order to properly init
    // the new W3C session
    this.capabilities = toW3cCapNames(this.capabilities);
  }