Exemple de test en JavaScript
Not for use with personal data
N'oubliez pas de consulter le guide d'installation d'Appium avec axe DevTools Mobile complet si vous débutez, ou d'autres exemples d'axe DevTools Mobile pour Appium dans d'autres langues.
executeScript en JavaScript
Lancez une analyse d'accessibilité en appelant ce qui suit dans vos tests JavaScript Appium :
const settings = { apiKey: '<your-api-key-here>' }
const result = await driver.execute('mobile: axeScan', settings)
Exemple complet avec 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);
Exemple complet avec 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);