mirror of
https://github.com/appium/appium.git
synced 2026-10-19 06:22:22 +08:00
04f6543561
* Sample code stub (#9887) * WD tests * WD sample code (#9918) * WebdriverIO sample code (#10166) * Ruby sample code (#10331) * PHP Sample Code (#10209) * Basic Android java test * Java sample code (#10427) * Sample code (#10834) * Sample code stub (#9887) * WD tests * WD sample code (#9918) * WebdriverIO sample code (#10166) * Ruby sample code (#10331) * PHP Sample Code (#10209) * Basic Android java test * Java sample code (#10427) * fixed WDIO test * Update .npmignore
63 lines
2.1 KiB
Ruby
63 lines
2.1 KiB
Ruby
require 'rubygems'
|
|
require 'appium_lib'
|
|
require 'test/unit'
|
|
extend Test::Unit::Assertions
|
|
|
|
PACKAGE = 'io.appium.android.apis'
|
|
SEARCH_ACTIVITY = '.app.SearchInvoke'
|
|
ALERT_DIALOG_ACTIVITY = '.app.AlertDialogSamples'
|
|
|
|
APP_PATH = ENV['SAUCE_LABS'] ? 'http://appium.github.io/appium/assets/ApiDemos-debug.apk' : '../apps/ApiDemos-debug.apk'
|
|
|
|
desired_caps = {
|
|
caps: {
|
|
platformName: 'Android',
|
|
platformVersion: ENV['SAUCE_LABS'] ? (ENV["ANDROID_PLATFORM_VERSION"] || '7.1') : ENV["ANDROID_PLATFORM_VERSION"],
|
|
deviceName: ENV["ANDROID_DEVICE_VERSION"] || 'Android',
|
|
app: APP_PATH,
|
|
automationName: 'UIAutomator2',
|
|
appActivity: SEARCH_ACTIVITY
|
|
},
|
|
appium_lib: {
|
|
sauce_username: ENV['SAUCE_LABS'] ? ENV['SAUCE_USERNAME'] : nil,
|
|
sauce_access_key: ENV['SAUCE_LABS'] ? ENV['SAUCE_ACCESS_KEY'] : nil,
|
|
wait: 60
|
|
}
|
|
}
|
|
|
|
describe 'Basic Android interactions' do
|
|
|
|
before(:all) do
|
|
@driver = Appium::Driver.new(desired_caps, true).start_driver
|
|
end
|
|
|
|
after(:all) do
|
|
@driver.quit
|
|
end
|
|
|
|
it 'should send keys to search box and then check the value' do
|
|
@search_box_element = @driver.find_element(:id, 'txt_query_prefill')
|
|
@search_box_element.send_keys('Hello world!')
|
|
|
|
@on_search_requested_button = @driver.find_element(:id, 'btn_start_search')
|
|
@on_search_requested_button.click()
|
|
|
|
@search_text = @driver.find_element(:id, 'android:id/search_src_text')
|
|
@search_text_value = @search_text.text()
|
|
expect(@search_text_value).to eql('Hello world!')
|
|
end
|
|
|
|
it 'should click a button that opens an alert and then dismisses it' do
|
|
@driver.start_activity app_package: PACKAGE, app_activity: ALERT_DIALOG_ACTIVITY
|
|
|
|
@open_dialog_button = @driver.find_element(:id, 'io.appium.android.apis:id/two_buttons')
|
|
@open_dialog_button.click()
|
|
|
|
@alert_element = @driver.find_element(:id, 'android:id/alertTitle')
|
|
@alert_text = @alert_element.text()
|
|
expect(@alert_text).to eql("Lorem ipsum dolor sit aie consectetur adipiscing\nPlloaso mako nuto siwuf cakso dodtos anr koop.")
|
|
@close_dialog_button = @driver.find_element(:id, 'android:id/button1')
|
|
|
|
@close_dialog_button.click()
|
|
end
|
|
end |