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

// Optional: Pause auto scan before a screen that shouldn't be included in scan results
await driver.executeScript('mobile: axePauseAutoScanSession', []);
const accountButton = await driver.$('~Account');
await accountButton.click();

// After passing the sensitive screen, resume auto scan
await driver.executeScript('mobile: axeResumeAutoScanSession', []);

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()

# Optional: Pause auto scan before a screen that shouldn't be included in scan results
driver.execute_script('mobile: axePauseAutoScanSession')
account_button = driver.find_element(AppiumBy.ACCESSIBILITY_ID, 'Account')
account_button.click()

# After passing the sensitive screen, resume auto scan
driver.execute_script('mobile: axeResumeAutoScanSession')

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

# Optional: Pause auto scan before a screen that shouldn't be included in scan results
@driver.execute_script('mobile: axePauseAutoScanSession')
account_button = @driver.find_element(:accessibility_id, 'Account')
account_button.click

# After passing the sensitive screen, resume auto scan
@driver.execute_script('mobile: axeResumeAutoScanSession')

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

// Optional: Pause auto scan before a screen that shouldn't be included in scan results
driver.executeScript("mobile: axePauseAutoScanSession");
WebElement accountButton = driver.findElement(AppiumBy.accessibilityId("Account"));
accountButton.click();

// After passing the sensitive screen, resume auto scan
driver.executeScript("mobile: axeResumeAutoScanSession");

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()

// Optional: Pause auto scan before a screen that shouldn't be included in scan results
driver.executeScript("mobile: axePauseAutoScanSession")
val accountButton = driver.findElement(AppiumBy.accessibilityId("Account"))
accountButton.click()

// After passing the sensitive screen, resume auto scan
driver.executeScript("mobile: axeResumeAutoScanSession")

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

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