Ejemplo de prueba en Ruby
Not for use with personal data
Asegúrate de consultar la completa Guía de configuración de Appium con axe DevTools Mobile si recién estás comenzando, o más ejemplos de axe DevTools Mobile para Appium en otros idiomas.
executeScript en Ruby
Inicie un análisis de accesibilidad llamando lo siguiente en sus pruebas Ruby Appium:
settings = { apiKey: '<your-api-key>' }
result = @driver.execute_script 'mobile: axeScan', settings
Ejemplo completo con UIAutomator2
require 'appium_lib_core'
require 'test/unit'
require 'json'
CAPABILITIES = {
platformName: 'Android',
// Please note "Axe" at the beginning of the driver's Automation Name
automationName: 'AxeUiAutomator2',
deviceName: 'Android',
appPackage: 'com.android.settings',
appActivity: '.Settings',
}
SERVER_URL = 'http://localhost:4723'
class AppiumPluginTest < Test::Unit::TestCase
def setup
@core = ::Appium::Core.for capabilities: CAPABILITIES
@driver = @core.start_driver server_url: SERVER_URL
end
def teardown
@driver&.quit
end
def runAccessibilityScan
settings = { apiKey: '<your-api-key-here>' }
result = @driver.execute_script 'mobile: axeScan', settings
puts JSON.pretty_generate(result)
end
end
Ejemplo completo con XCUITest
require 'appium_lib_core'
require 'test/unit'
require 'json'
CAPABILITIES = {
platformName: 'iOS',
// Please note "Axe" at the beginning of the driver's Automation Name
automationName: 'AxeXCUITest',
bundleId: 'com.dequesystems.axe-devtools-ios-sample-app',
udid: '...' # xcrun simctl list | grep Booted
}
SERVER_URL = 'http://localhost:4723'
class AppiumPluginTest < Test::Unit::TestCase
def setup
@core = ::Appium::Core.for capabilities: CAPABILITIES
@driver = @core.start_driver server_url: SERVER_URL
end
def teardown
@driver&.quit
end
def runAccessibilityScan
settings = { apiKey: '<your-api-key>' }
result = @driver.execute_script 'mobile: axeScan', settings
puts JSON.pretty_generate(result)
end
end