模拟器是:android4.4.2 已装
平台:windows
环境搭建:appium 已装,ruby 已装
D 盘下有 ContactManager.apk
appium 服务正常启动
运行脚本:
D:\>ruby test_contact.rb
c:/Ruby192/lib/ruby/1.9.1/net/protocol.rb:140:in `rescue in rbuf_fill': Timeout::Error (Timeout::Error)
from c:/Ruby192/lib/ruby/1.9.1/net/protocol.rb:134:in `rbuf_fill'
from c:/Ruby192/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil'
from c:/Ruby192/lib/ruby/1.9.1/net/protocol.rb:126:in `readline'
from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:2219:in `read_status_line'
from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:2208:in `read_new'
from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:1191:in `transport_request'
from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:1177:in `request'
from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:627:in `start'
from c:/Ruby192/lib/ruby/1.9.1/net/http.rb:1168:in `request'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/remote/bridge.rb:634:in `raw_execute'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/remote/bridge.rb:99:in `create_session'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/driver.rb:33:in `new'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver/common/driver.rb:33:in `for'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.40.0/lib/selenium/webdriver.rb:67:in `for'
from test_contact.rb:18:in `<main>'
appium 返回如下:
info: Welcome to Appium v0.14.2
info: Appium REST http interface listener started on 127.0.0.1:4723
info - socket.io started
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"device":"Android",
bwserName":"","version":"4.4.2","platform":"windows","app":"D:\\ContactManage
.k","app-package":"com.example.android.contactmanager","app-activity":".Conta
tnager"}}
info: Using local app from desiredCaps: D:\ContactManager.apk
info: Creating new appium session cb934492-7ace-4a90-a838-94a426878003
info: Starting android appium
debug: Using fast reset? false
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
POST /wd/hub/session 200 59999ms
脚本如下:
require "selenium-webdriver"
app_name='ContactManager.apk'
path_for_app = 'D:\\'+ app_name
capabilities = {"device"=>"Android",
"browserName"=>"",
"version"=> "4.4.2",
"platform"=>"windows",
"app"=>path_for_app,
"app-package"=>"com.example.android.contactmanager",
"app-activity"=>".ContactManager"}
driver = Selenium::WebDriver.for(:remote,:desired_capabilities => capabilities, :url =>"http://127.0.0.1:4723/wd/hub")
driver.manage.timeouts.implicit_wait = 10
new_button = driver.find_element(:name, "Add Contact")
new_button.click
driver.close unless driver.nil?
driver=nil
求帮忙下,谢谢