2011-09-28 66 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' 
相关问题