Files
appium/sample-code/examples/ruby/xunit_android.rb
Dylan Lacey 633c2ed81e Update Ruby sample code.
Change from tag_name to class_name for u\_i\_catalog, simple\_test,
cucumber tests.

Changed to iOS 7.1 in u\_i\_catalog, simple\_test, cucumber tests.

Changed `capabilities` to `desired_caps` to avoid some weirdo
collisions.

Remove Debugging output from Cucumber.

Add example of send\_keys as an action chain for u\_i\_catalog.
2014-04-01 01:46:27 -07:00

51 lines
1.4 KiB
Ruby

# this test show you how to use flick and locate element by parent container
# 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'
def desired_caps
{
'browserName' => 'android',
'platform' => 'linux',
'version' => '4.1',
'app-activity'=> '.Settings',
'app-package'=> 'com.android.settings'
}
end
def init(data={})
server_url = 'http://127.0.0.1:4723/wd/hub'
driver = Selenium::WebDriver.for(:remote, :desired_capabilities => desired_caps.merge(data), :url => server_url)
driver.manage.timeouts.implicit_wait = 20 # seconds
driver
end
class SettingsTest < Test::Unit::TestCase
def setup
@driver=init
end
def test_settings
#flick the screen until find the Aboud phone item
while @driver.find_elements(:xpath, '//text[@text="About phone"]').count==0
begin
@driver.execute_script 'mobile: flick', :startY=>0.9, :endY=>0.1
rescue
end
end
about=@driver.find_element(:xpath, '//text[@text="About phone"]')
about.click
#parent select, locate the container
version_setting=@driver.find_element(:xpath, '//list/linear[4]/relative')
#child select
version_value=version_setting.find_element(:xpath, '//text[2]')
#check the version, should be 4.1.2 or other version string
assert_not_equal nil, version_value.text=~/[0-9\.]/
end
def teardown
@driver.quit
end
end