How to use appium-base-driver - 10 common examples

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 / test / e2e / safari / page-load-timeout-specs.js View on Github external
it('should not go to the requested page', async function () {
      await driver.timeouts({protocol: PROTOCOLS.MJSONWP, type: 'page load', ms: 5000}, '1dcfe021-8fc8-49bd-8dac-e986d3091b97');
      await driver.setUrl(env.GUINEA_TEST_END_POINT + '?delay=30000');

      // the page should not have time to load
      (await driver.getPageSource()).should.include('Let\'s browse!');
    });
  });
github appium / appium-ios-driver / test / e2e / safari / page-load-timeout-specs.js View on Github external
it('should go to the requested page', async function () {
      await driver.timeouts({protocol: PROTOCOLS.MJSONWP, type: 'command', ms: 120000}, '1dcfe021-8fc8-49bd-8dac-e986d3091b97');
      await driver.timeouts({protocol: PROTOCOLS.MJSONWP, type: 'page load', ms: 0}, '1dcfe021-8fc8-49bd-8dac-e986d3091b97');
      await driver.setUrl(env.GUINEA_TEST_END_POINT + '?delay=5000');

      // the page should load after 70000
      (await driver.getPageSource()).should.include('I am some page content');
      (Date.now() - startMs).should.be.above(5000);
    });
  });
github appium / appium-android-driver / test / unit / driver-specs.js View on Github external
it('should respect timeout if autoWebview is requested', async function () {
      this.timeout(10000);
      driver.setContext.throws(new errors.NoSuchContextError());

      let begin = Date.now();

      driver.opts.autoWebview = true;
      driver.opts.autoWebviewTimeout = 5000;
      await driver.startAndroidSession().should.eventually.be.rejected;
      driver.defaultWebviewName.calledOnce.should.be.true;

      // we have a timeout of 5000ms, retrying on 500ms, so expect 10 times
      driver.setContext.callCount.should.equal(10);

      let end = Date.now();
      (end - begin).should.be.above(4500);
    });
    it('should not set the context if autoWebview is not requested', async function () {
github appium / appium-xcuitest-driver / lib / commands / context.js View on Github external
// switching into a webview context

  // if contexts have not already been retrieved, get them
  if (_.isUndefined(this.contexts)) {
    await this.getContexts();
  }

  let contextId = _.replace(name, WEBVIEW_BASE, '');
  if (contextId === '') {
    // allow user to pass in "WEBVIEW" without an index
    // the second context will be the first webview as
    // the first is always NATIVE_APP
    contextId = this.contexts[1];
  }
  if (!_.includes(this.contexts, contextId)) {
    throw new errors.NoSuchContextError();
  }

  const oldContext = this.curContext;
  this.curContext = this.curWindowHandle = contextId;

  // `contextId` will be in the form of `appId.pageId` in this case
  const [appIdKey, pageIdKey] = _.map(contextId.split('.'), (id) => parseInt(id, 10));
  try {
    this.selectingNewPage = true;
    await this.remote.selectPage(appIdKey, pageIdKey, skipReadyCheck);
  } catch (err) {
    this.curContext = this.curWindowHandle = oldContext;
    throw err;
  } finally {
    this.selectingNewPage = false;
  }
github appium / appium-xcuitest-driver / lib / commands / context.js View on Github external
commands.getWindowHandle = async function getWindowHandle () { // eslint-disable-line require-await
  if (!this.isWebContext()) {
    throw new errors.NotImplementedError();
  }
  log.debug(`Getting current window handle`);
  return this.curContext;
};
github appium / appium-xcuitest-driver / lib / commands / element.js View on Github external
commands.getContentSize = async function getContentSize (el) {
  if (this.isWebContext()) {
    throw new errors.NotYetImplementedError('Support for getContentSize for web context is not yet implemented. Please contact an Appium dev');
  }

  const type = await this.getAttribute('type', el);

  if (type !== 'XCUIElementTypeTable' &&
      type !== 'XCUIElementTypeCollectionView') {
    throw new Error(`Can't get content size for type '${type}', only for ` +
                    `tables and collection views`);
  }
  let locator = '*';
  if (type === 'XCUIElementTypeTable') {
    // only find table cells, not just any children
    locator = 'XCUIElementTypeCell';
  }

  let contentHeight = 0;
github appium / appium-ios-driver / test / e2e / setup-base.js View on Github external
async function startServer (session) {
  // start the server before start the session, so startup can use it if necessary
  server = await baseServer({
    routeConfiguringFunction: routeConfiguringFunction(session.rawDriver),
    port: env.APPIUM_PORT,
    hostname: 'localhost',
  });
  log.info(`IosDriver server listening on http://localhost:${env.APPIUM_PORT}`);
}
github appium / appium-xcuitest-driver / lib / server.js View on Github external
async function startServer (port, address) {
  const driver = new XCUITestDriver({port, address});
  const server = await baseServer({
    routeConfiguringFunction: routeConfiguringFunction(driver),
    port,
    hostname: address,
    allowCors: false,
  });
  // make the driver available
  server.driver = driver;
  log.info(`XCUITestDriver server listening on http://${address}:${port}`);
  return server;
}
github appium / appium-ios-driver / test / e2e / setup-base.js View on Github external
async function startServer (session) {
  // start the server before start the session, so startup can use it if necessary
  server = await baseServer({
    routeConfiguringFunction: routeConfiguringFunction(session.rawDriver),
    port: env.APPIUM_PORT,
    hostname: 'localhost',
  });
  log.info(`IosDriver server listening on http://localhost:${env.APPIUM_PORT}`);
}
github appium / appium-xcuitest-driver / lib / server.js View on Github external
async function startServer (port, address) {
  const driver = new XCUITestDriver({port, address});
  const server = await baseServer({
    routeConfiguringFunction: routeConfiguringFunction(driver),
    port,
    hostname: address,
    allowCors: false,
  });
  // make the driver available
  server.driver = driver;
  log.info(`XCUITestDriver server listening on http://${address}:${port}`);
  return server;
}