尝试自动化时,Android Driver抛出错误

时间:2013-09-30 13:29:06

标签: android ruby selenium android-emulator webdriver

我正在尝试使用带有ruby脚本的selenium(Android驱动程序)自动化移动浏览器, 这是同样的示例脚本

require 'selenium-webdriver'
require "selenium/client"
caps = Selenium::WebDriver::Remote::Capabilities.android  
client = Selenium::WebDriver::Remote::Http::Default.new  
client.timeout = 480  
driver = Selenium::WebDriver.for(  
  :remote,  
  :url => "http://localhost:8080/wd/hub/",  
  :http_client => client,  
  :desired_capabilities => caps)  
driver.navigate.to "http://www.google.com"  
element = driver.find_element(:name, 'q')  
element.send_keys "Example google"
element.submit  
puts driver.title  
driver.quit

它执行步骤直到sendkeys,步骤但之后,它抛出错误,捕获错误是

EOFError: end of file reached
        from C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:153:in `read_nonblock'
        from C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:153:in `rbuf_fill'
        from C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil'
        from C:/Ruby200/lib/ruby/2.0.0/net/protocol.rb:144:in `readline'
        from C:/Ruby200/lib/ruby/2.0.0/net/http/response.rb:39:in `read_status_l
ine'
        from C:/Ruby200/lib/ruby/2.0.0/net/http/response.rb:28:in `read_new'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1406:in `block in transport_r
equest'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1403:in `catch'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1403:in `transport_request'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1376:in `request'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1369:in `block in request'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:852:in `start'
        from C:/Ruby200/lib/ruby/2.0.0/net/http.rb:1367:in `request'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/s
elenium/webdriver/remote/http/default.rb:83:in `response_for'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/s
elenium/webdriver/remote/http/default.rb:39:in `request'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/s
elenium/webdriver/remote/http/common.rb:40:in `call'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/s
elenium/webdriver/remote/bridge.rb:634:in `raw_execute'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/s
elenium/webdriver/remote/bridge.rb:612:in `execute'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/s
elenium/webdriver/remote/bridge.rb:428:in `submitElement'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/s
elenium/webdriver/common/element.rb:179:in `submit'
        from (irb):14
        from C:/Ruby200/bin/irb:12:in `<main>'irb(main):015:0> puts driver.title

我还尝试了IRB中的所有命令来确认它不是由于超时异常。 请提出建议,究竟是什么问题以及如何在移动浏览器自动化中克服这种情况。

提前致谢:)

1 个答案:

答案 0 :(得分:0)

我在针对真实设备和模拟器进行自动化时遇到了EOF错误(虽然在不同的点)。

解决方案是卸载新的android-server-2.32.0.apk并安装旧版本android-server-2.21.0.apk。