Esempio di test in 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

Assicurati di consultare la Guida completa alla configurazione di Appium con axe DevTools Mobile se hai appena iniziato, o altri esempi di axe DevTools Mobile per Appium in altre lingue.

executeScript in JavaScript

Avvia una scansione di accessibilità chiamando quanto segue nei tuoi test Appium JavaScript:

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

Esempio 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);

Esempio 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);