[英]Using Android UIAutomator in Python or Ruby
我正在嘗試通過鏈接到android SDK中提供的UIAutomator來使用python(或可能是ruby)來自動化android應用。
現在,我嘗試在此處使用Python工具,但連接時遇到問題(獲取TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
。
代碼刪除了我要使用Python工具執行的操作:
def print_info():
print('Getting info...')
d = ui.Device('SERIAL_NUMBER', adb_server_host='192.168.1.20', adb_server_port='5037')
print(d.info)
我嘗試發送命令的方式有問題嗎? 另外,是否有更好的ruby / python工具來測試android設備?
更新我現在正在使用Appium庫Ruby gem進行測試。 有啟動的應用程序,但是點擊屏幕之類的東西會導致此錯誤
assert_ok': A session is either terminated or not started
(Selenium::WebDriver::Error::NoSuchDriverError)`
這是代碼
desired_caps = {
caps: {
appiumVersion: '1.6.5',
platformName: 'Android',
platformVersion: '4.4',
browserName: '',
deviceName: 'DEVICE_SERIAL',
app: 'APK',
appActivity: 'mainactivity',
appWaitDuration: '60000', # wait a minute (set to 20000 by default)
clearSystemFiles: 'true'
},
appium_lib: {
sauce_username: nil,
sauce_access_key: nil
}
}
$driver = Appium::Driver.new(desired_caps)
$driver.start_driver
sleep(60) # wait a minute for app to fully load, before tring to tap anything
touch_action = Appium::TouchAction.new
touch_action.press(x: 243, y: 288).wait(5).release.perform
touch_action.press(x: 311, y: 165).wait(5).release.perform
有一個很好的移動測試自動化工具-Appium。 目前,我一直在使用ruby,appium,cucumber,selenium webdriver進行android自動化。 我建議您嘗試將Appium工具用於移動自動化。 以下是重要的鏈接,
http://www.software-testing-tutorials-automation.com/2015/09/appium-tutorials.html https://community.perfectomobile.com/posts/1103155-ruby-example-for-appium-android http: //appium.io/slate/en/tutorial/android.html?ruby#troubleshooting
following is the example to start
require 'appium_lib'
desired_caps = {
caps: { appiumVersion: '1.6.0',
platformName: 'Android',
platformVersion: '4.4.2',
browserName: '',
deviceName: 'Samsung Galaxy S4 Emulator',
app: 'D:\Workspace\android-sample-app.apk',
name: 'Ruby Appium Sauce example'
} }
driver = Appium::Driver.new(desired_caps)
puts driver
begin
driver.start_driver
rescue Exception => e
puts e
end
driver.first_textfield.send_key 10
driver.last_textfield.send_key 20
driver.first_button.click
driver.driver_quit
download "android-sample-app.apk" and put in any path and also set this path
in desired_caps.
謝謝,Kapil Chothe
這就是我為模擬器做的方式
app_path = File.absolute_path('automateme.apk', 'data')
caps = {
:platformName => "android",
:deviceName => "android",
:app => app_path,
:noReset => 'true',
:newCommandTimeout => "30"
}
@driver = Appium::Driver.new(:caps => caps).start_driver
試試這個,讓我知道是否有幫助... :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.