Exemple de test en Ruby
Not for use with personal data
N'oubliez pas de consulter le guide d'installation d'Appium avec axe DevTools Mobile complet si vous débutez, ou d'autres exemples d'axe DevTools Mobile pour Appium dans d'autres langues.
executeScript en Ruby
Lancez une analyse d'accessibilité en appelant ce qui suit dans vos tests Ruby Appium :
settings = { apiKey: '<your-api-key>' }
result = @driver.execute_script 'mobile: axeScan', settings
Exemple complet avec 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
Exemple complet avec 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