Testbeispiel in Ruby
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 Ruby
Starten Sie einen Erreichbarkeitsscan, indem Sie in Ihren Ruby-Appium-Tests Folgendes aufrufen:
settings = { apiKey: '<your-api-key>' }
result = @driver.execute_script 'mobile: axeScan', settings
Vollständiges Beispiel mit 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
Vollständiges Beispiel mit 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