Ejemplo de prueba en JavaScript

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard
Not for use with personal data

Asegúrate de consultar la completa Guía de configuración de Appium con axe DevTools Mobile si recién estás comenzando, o más ejemplos de axe DevTools Mobile para Appium en otros idiomas.

executeScript en JavaScript

Inicie un análisis de accesibilidad llamando lo siguiente en sus pruebas de Appium de JavaScript:

const settings = { apiKey: '<your-api-key-here>' }
const result = await driver.execute('mobile: axeScan', settings)

Ejemplo completo con UIAutomator2

const {remote} = require('webdriverio');

const wdOpts = {
  hostname: process.env.APPIUM_HOST || 'localhost',
  port: parseInt(process.env.APPIUM_PORT, 10) || 4723,
  logLevel: 'info',
  capabilities: {
    platformName: 'Android',
    // Please note "Axe" at the beginning of the driver's Automation Name
    'appium:automationName': 'AxeUiAutomator2',
    'appium:deviceName': 'Android',
    'appium:appPackage': 'com.android.settings',
    'appium:appActivity': '.Settings',
  }
}

async function runAccessibilityScan() {
  const driver = await remote(wdOpts);
  try {
    const settings = { apiKey: '<your-api-key-here>' }
    const result = await driver.execute('mobile: axeScan', settings)
  } finally {
    await driver.pause(1000);
    await driver.deleteSession();
  }
}

runAccessibilityScan().catch(console.error);

Ejemplo completo con XCUITest

const {remote} = require('webdriverio');

const wdOpts = {
  hostname: process.env.APPIUM_HOST || 'localhost',
  port: parseInt(process.env.APPIUM_PORT, 10) || 4723,
  logLevel: 'info',
  capabilities: {
    platformName: 'iOS',
    // Please note "Axe" at the beginning of the driver's Automation Name
    'appium:automationName': 'AxeXCUITest',
    'appium:udid': '...', // xcrun simctl list | grep Booted
    'appium:bundleId': 'com.dequesystems.axe-devtools-ios-sample-app'
  }
}

async function runAccessibilityScan() {
  const driver = await remote(wdOpts);
  try {

    const settings = { apiKey: '<your-api-key-here>' }
    const result = await driver.execute('mobile: axeScan', settings)
 
  } finally {
    await driver.pause(1000);
    await driver.deleteSession();
  }
}

runAccessibilityScan().catch(console.error);