2011-09-28 61 views
2

我是Watir-webdriver的新手。 我曾嘗試在http://bit.ly/watir-example使用Watir-Webdriver驅動IE的錯誤:無法使用xpath查找元素

我試圖在互聯網上Exploerer(IE版本8)運行使用Firefox的Watir-webdriver的,但它不工作。 我也設置了具有相同值的IE保護值。 我的代碼是這樣簡單:

browser = Watir::Browser.new :ie 
browser.goto 'http://bit.ly/watir-example' 
sleep 5 
browser.text_field(:name => 'entry.0.single').set 'My Name' 

的錯誤消息,我得到的是這樣的:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.6.0/lib/selenium/webdriver/remote/response.rb:45:in `assert_ok': Unable to find element with xpath == .//input[(not(@type) or (@type!="file" and @type!="radio" and @type!="checkbox" and @type!="submit" and @type!="reset" and @type!="image" and @type!="button" and @type!="hidden" and @type!="datetime" and @type!="date" and @type!="month" and @type!="week" and @type!="time" and @type!="datetime-local" and @type!="range" and @type!="color")) and @name='entry.0.single'] | .//textarea[@name='entry.0.single'] (Selenium::WebDriver::Error::UnexpectedJavascriptError)

誰能幫助我嗎? 謝謝。

回答

1

使用irb爲您提供一些詳細信息,關於您的問題

如。

> irb 
> require 'watir-webdriver' 
> browser = Watir::Browser.new :ie 
> browser.goto 'http://bit.ly/watir-example' 
> puts browser.title 
> puts browser.text_fields.count 
> browser.text_field.set 'hello' 
相關問題