以下宝石是最新的:rubygems,watir,selenium-webdriver。
我在命令行执行以下操作:
$irb
>require 'watir' (returns true)
>BROWSER=Watir::Browser.new :firefox (returns #<Watir::Browser:0x2b7c618 url="about:blank" title="">)
>BROWSER.goto('google.ca') (returns "http://google.ca")
>BROWSER.text_field(:name => 'q').exists? (returns true)
>BROWSER.text_field(:name => 'q').set('test')
此时我收到以下错误:
Selenium::WebDriver::Error::ServerError: status code 400
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/response.rb:74:in 'assert_ok'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/response.rb:34:in 'initialize'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/http/common.rb:83:in 'new'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/http/common.rb:83:in 'create_response'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/http/default.rb:106:in 'request'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/http/common.rb:61:in 'call'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/bridge.rb:170:in 'execute'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/w3c/bridge.rb:537:in 'execute'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/w3c/bridge.rb:367:in 'send_keys_to_element'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/common/element.rb:156:in 'send_keys'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/watir-6.8.4/lib/watir/user_editable.rb:13:in 'block in set'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/watir-6.8.4/lib/watir/elements/element.rb:657:in 'element_call'
from C:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/watir-6.8.4/lib/watir/user_editable.rb:11:in `set'
from (irb):19
from C:/Ruby21-x64/bin/irb:11:in '<main>'
我也尝试了.send_keys(&#39; test&#39;)并得到了同样的错误。如果它能找到元素,我就不明白为什么我不能在元素中输入文字。