Esempio di test in Ruby

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

Assicurati di consultare la Guida completa alla configurazione di Appium con axe DevTools Mobile se hai appena iniziato, o altri esempi di axe DevTools Mobile per Appium in altre lingue.

executeScript in Ruby

Avvia una scansione di accessibilità chiamando quanto segue nei tuoi test Ruby Appium:

settings = { apiKey: '<your-api-key>' }
result =  @driver.execute_script 'mobile: axeScan', settings

Esempio 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

Esempio 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