Testbeispiel in Python

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

Schauen Sie sich unbedingt die vollständige Appium-Setup-Anleitung mit axe DevTools Mobile an, wenn Sie gerade erst anfangen, oder weitere Beispiele für axe DevTools Mobile für Appium in anderen Sprachen.

executeScript in Python

Starten Sie einen Zugänglichkeitsscan, indem Sie in Ihren Python-Appium-Tests Folgendes aufrufen:

settings = {}
settings['apiKey'] = "<your-api-key-here>"
result = self.driver.execute_script('mobile: axeScan', settings)

Vollständiges Beispiel mit UIAutomator2

from appium import webdriver
from appium.options.android import UiAutomator2Options
from appium.webdriver.appium_connection import AppiumConnection
import json

class AppiumPluginTest:

    def setup(self):
        success = True
        desired_caps = {}

        desired_caps['platformName'] = 'Android'
        // Please note "Axe" at the beginning of the driver's Automation Name
        desired_caps['automationName'] = 'AxeUiAutomator2'
        desired_caps['appPackage'] = "com.android.settings"
        desired_caps['appActivity'] = ".Settings"

        options = UiAutomator2Options().load_capabilities(desired_caps)
        self.driver = webdriver.Remote('http://localhost:4723', options=options)

    def runAccessibilityScan(self):
        settings = {}
        settings['apiKey'] = "<your-api-key-here>"
        return self.driver.execute_script('mobile: axeScan', settings)


demo = AppiumPluginTest()
demo.setup()

result = demo.runAccessibilityScan()

Vollständiges Beispiel mit XCUITest

from appium import webdriver
from appium.options.ios import XCUITestOptions
from appium.webdriver.appium_connection import AppiumConnection
import json

class AppiumPluginTest:

    def setup(self):
        success = True
        desired_caps = {}

        desired_caps['platformName'] = 'iOS'
        // Please note "Axe" at the beginning of the driver's Automation Name
        desired_caps['automationName'] = 'AxeXCUITest'
        desired_caps['bundleId'] = 'com.dequesystems.axe-devtools-ios-sample-app'
        desired_caps['udid'] = '...' # xcrun simctl list | grep Booted

        options = XCUITestOptions().load_capabilities(desired_caps)
        self.driver = webdriver.Remote('http://localhost:4723', options=options)

    def runAccessibilityScan(self):
        settings = {}
        settings['apiKey'] = "<your-api-key-here>"
        return self.driver.execute_script('mobile: axeScan', settings)


demo = AppiumPluginTest()
demo.setup()

result = demo.runAccessibilityScan()