Migrate Appium Plugin to Appium Driver Solution

Link to Migrate Appium Plugin to Appium Driver Solution copied to clipboard

Guide to migrate early adopters to the latest changes of axe DevTools Mobile for Appium.

Free Trial

Note: If you are just getting started with axe DevTools Mobile for Appium, head over to the setup guide.

We’re excited to announce two new Appium drivers for an industry-leading Appium accessibility testing solution. Our drivers are powered by our proven SDKs giving you the same robust and highly accurate results you get with all of our axe DevTools Mobile components. Our Appium drivers cover all of Deque’s available mobile rules and setup only takes minutes.

If you implemented version 2.0.0+ of the axe DevTools Mobile Appium plugin, follow this guide to easily switch to the driver solution.

Uninstall the plugin

appium plugin uninstall axeDevToolsMobile

Install the Drivers

Install the required drivers to your Appium instance through the command line:

axe XCUITest Driver for iOS Testing

appium driver install --source=npm @axe-devtools/axe-appium-xcuitest-driver

If you need to uninstall at any time, you can uninstall through the command line:

appium driver uninstall axexcuitest

axe UIAutomator2 Driver for Android Testing

appium driver install --source=npm @axe-devtools/axe-appium-uiautomator2-driver

If you need to uninstall at any time, you can uninstall through the command line:

appium driver uninstall axeuiautomator2

Start Accessibility Testing Through Appium

Start the Appium server as normal:

appium

Configure Your Tests

Much of the setup code for the Appium plugin can be re-used for the Appium axe drivers.

Updates

  1. New with the driver solution is updating your capability for automationName to either AxeXCUITest for iOS testing or AxeUiAutomator2 for Android testing.

  2. To avoid conflicts, the driver.execute code should be updated to await driver.execute('mobile: axeScan', axeSettings), where axeSettings object is still the same object containing the apiKey and other customizations.

Full Examples

axe UiAutomator2 Driver Example with Python Tests

While the below example is written in Python, the logic is transferable to other Appium client libraries.


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

class DemoWithAxeDevToolsMobile:

    def setup(self):
        success = True
        desired_caps = {}
        # Add your required capabilities for testing:
        desired_caps['platformName'] = 'Android'
        desired_caps['appActivity'] = "com.app.package.MainActivity"

        # Add axe DevTools Mobile required capabilities for testing:
        desired_caps['appPackage'] = "com.app.package"
        desired_caps['automationName'] = 'AxeUiAutomator2'

        # Initialize Appium Server Connection
        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 = DemoWithAxeDevToolsMobile()
demo.setup()

# <Navigate To Screen>
demo.runAccessibilityScan()

# <Navigate To Another Screen>
demo.runAccessibilityScan()

axe XCUITest Driver Example with Python Tests

While the below example is written in Python, the logic is transferable to other Appium client libraries.


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

class DemoWithAxeDevToolsMobile:

    def setup(self):
        success = True
        desired_caps = {}
        # Add your required capabilities for testing:
        desired_caps['platformName'] = 'iOS'

        # Add axe DevTools Mobile required capabilities for testing:
        desired_caps['bundleId'] = "com.bundle.identifier"
        desired_caps['automationName'] = 'AxeXCUITest'

        # Initialize Appium Server Connection
        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 = DemoWithAxeDevToolsMobile()
demo.setup()

# Navigate To Screen
demo.runAccessibilityScan()

# Navigate To Another Screen
demo.runAccessibilityScan()