mirror of
https://github.com/appium/appium.git
synced 2026-01-13 22:00:05 -06:00
38 lines
1.1 KiB
Ruby
38 lines
1.1 KiB
Ruby
# this test show you how to use scroll and locate element by xpath
|
|
# it open the system settings ui, and click the 'About phone' item to find android version
|
|
# create by testerhome.com
|
|
# author: seveniruby
|
|
#
|
|
# run using:
|
|
# bundle exec ruby xunit_android.rb
|
|
|
|
require 'rubygems'
|
|
require 'test/unit'
|
|
require 'appium_lib'
|
|
|
|
class SettingsTest < Test::Unit::TestCase
|
|
def setup
|
|
caps = { caps: { platformName: 'Android', appActivity: '.Settings', appPackage: 'com.android.settings' },
|
|
appium_lib: { sauce_username: nil, sauce_access_key: nil } }
|
|
driver = Appium::Driver.new(caps)
|
|
Appium.promote_appium_methods self.class
|
|
driver.start_driver.manage.timeouts.implicit_wait = 20 # seconds
|
|
end
|
|
|
|
def teardown
|
|
driver_quit
|
|
end
|
|
|
|
def test_about_phone_version
|
|
scroll_to('About phone').click
|
|
android_version = 'Android version'
|
|
scroll_to android_version
|
|
|
|
view = 'android.widget.TextView'
|
|
version = xpath(%Q(//#{view}[preceding-sibling::#{view}[@text="#{android_version}"]])).text
|
|
valid = !version.match(/\d/).nil?
|
|
|
|
puts "Version is: #{version}"
|
|
assert_equal true, valid
|
|
end
|
|
end |