mirror of
https://github.com/appium/appium.git
synced 2026-01-14 06:10:01 -06:00
34 lines
1.0 KiB
Ruby
34 lines
1.0 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
|
|
|
|
require 'test/unit'
|
|
require 'selenium-webdriver'
|
|
require 'appium_lib'
|
|
|
|
class SettingsTest < Test::Unit::TestCase
|
|
def setup
|
|
caps = { caps: { platformName: 'Android', appActivity: '.Settings', appPackage: 'com.android.settings' } }
|
|
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 |