我正在尝试使用带有 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
它执行步骤 until sendkeys
, step 但之后,它抛出错误,捕获的错误是
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
以确认它不是由于超时异常。请建议,究竟是什么问题以及如何从移动浏览器自动化中的这种场景中克服。
提前致谢 :)