Ruby+watir高手进!!uninitialized constant Watir::NonControlElement (NameError)

softtechnology 2014-11-17 04:39:13
我想实现页面上tree 的点击动作,可是页面看到的标签是
<FONT style="CURSOR: hand" id=id52 class=nodeSel title=外拨管理 target="_self" src="img/base.gif">外拨管理</FONT>
而<font>标签 watir不能识别,所以使用自定义标签。

但是一执行 ruby脚本,提示:
F:/Ruby/autoInspect.rb:13:in `<module:Watir>': uninitialized constant Watir::NonControlElement (NameError)
from F:/Ruby/autoInspect.rb:12:in `<main>'
[Finished in 0.7s]


代码如下:
#encoding: utf-8
#require "rubygems"
require 'watir'
require 'watir-webdriver'
#require 'watir-classic'
require "yaml"
require "rexml/document"
include REXML



module Watir
class Font < NonControlElement
TAG = 'font'
end
module Container
def font(how, what)
return Font.new(self, how, what)
end
end
end



谁能帮忙看一看????????????是不是需要额外引入什么命名空间啊

...全文
248 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
softtechnology 2014-11-24
  • 打赏
  • 举报
回复
不可以呢,还是要谢谢你啊 :/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- watir/ie (LoadError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from F:/Ruby/autoInspect.rb:8:in `<main>' [Finished in 6.6s with exit code 1]
panghuhu250 2014-11-17
  • 打赏
  • 举报
回复
这儿(https://groups.google.com/forum/#!msg/watir-general/kBAGiswpeq4/kqcEfHFaLeEJ) 说,在前面加上
require 'watir/ie'
上面网页里的解释(by Bret):The reason for this is as follows. The "watir" library (what you require 'watir' to get), used to be the Watir::IE class and supporting code. Now that library is called "watir/ie". There is now a new library called "watir" (contained in the commonwatir gem, actually) that loads the correct library. It will load 'watir/ie' if (1) you use Browser.new and your browser option is 'ie' or (2) if you make any reference to Watir::IE. Bret

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧