Auto Scan Code Examples with XCUITest

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

JavaScript (WebDriverIO)

// Start auto scan session
await driver.execute('mobile: axeStartAutoScanSession', {
  axeMobileApiKey: 'YOUR_API_KEY',
  axeServerUrl: 'YOUR_SERVER_URL', //This should be used for on-prem or private cloud
  axeProjectId: 'YOUR_PROJECT_ID'
});

// Navigate through the app
const settingsButton = await driver.$('~Settings');
await settingsButton.click();

const generalButton = await driver.$('~General');
await generalButton.click();

// Stop auto scan and generate report
await driver.execute('mobile: axeStopAutoScanSession', {});

Python

# Start auto scan session
driver.execute_script('mobile: axeStartAutoScanSession', {
    'axeMobileApiKey': 'YOUR_API_KEY',
    'axeServerUrl': 'YOUR_SERVER_URL', #This should be used for on-prem or private cloud
    'axeProjectId': 'YOUR_PROJECT_ID'
})

# Navigate through the app
settings_button = driver.find_element(AppiumBy.ACCESSIBILITY_ID, 'Settings')
settings_button.click()

general_button = driver.find_element(AppiumBy.ACCESSIBILITY_ID, 'General')
general_button.click()

# Stop auto scan and generate report
driver.execute_script('mobile: axeStopAutoScanSession', {})

Ruby

# Start auto scan session
@driver.execute_script('mobile: axeStartAutoScanSession', {
  'axeMobileApiKey' => 'YOUR_API_KEY',
  'axeServerUrl' => 'YOUR_SERVER_URL', #This should be used for on-prem or private cloud
  'axeProjectId' => 'YOUR_PROJECT_ID'
})

# Navigate through the app
settings_button = @driver.find_element(:accessibility_id, 'Settings')
settings_button.click

general_button = @driver.find_element(:accessibility_id, 'General')
general_button.click

# Stop auto scan and generate report
@driver.execute_script('mobile: axeStopAutoScanSession', {})

Java

// Start auto scan session
Map<String, Object> params = new HashMap<>();
params.put("axeMobileApiKey", "YOUR_API_KEY");
params.put("axeServerUrl", "YOUR_SERVER_URL"); //This should be used for on-prem or private cloud
params.put("axeProjectId", "YOUR_PROJECT_ID");
driver.executeScript("mobile: axeStartAutoScanSession", params);

// Navigate through the app
WebElement settingsButton = driver.findElement(AppiumBy.accessibilityId("Settings"));
settingsButton.click();

WebElement generalButton = driver.findElement(AppiumBy.accessibilityId("General"));
generalButton.click();

// Stop auto scan and generate report
driver.executeScript("mobile: axeStopAutoScanSession", new HashMap<>());

Kotlin

// Start auto scan session
val params = mapOf(
    "axeMobileApiKey" to "YOUR_API_KEY",
    "axeServerUrl" to "YOUR_SERVER_URL", //This should be used for on-prem or private cloud
    "axeProjectId" to "YOUR_PROJECT_ID"
)
driver.executeScript("mobile: axeStartAutoScanSession", params)

// Navigate through the app
val settingsButton = driver.findElement(AppiumBy.accessibilityId("Settings"))
settingsButton.click()

val generalButton = driver.findElement(AppiumBy.accessibilityId("General"))
generalButton.click()

// Stop auto scan and generate report
driver.executeScript("mobile: axeStopAutoScanSession", emptyMap<String, Any>())