Ruby学习笔记_watir

错误现象:

uninitialized constant Watir::IE (NameError)


解决方案:

1. gem update --system 

2. gem install watir 

3. gem install win32-process

4. gem install watir-classic         #目前还不支持64位的Ruby所以安装的Ruby必须是32位的才能使用

第一个是对Rubygems升级,第二个是对安装watir。这两个过程都是要通过网络的。

3. 用rb文件测试: 

require 'rubygems'
require 'watir'
require 'watir-classic' 

ie = Watir::Browser.new
ie.goto("http://www.baidu.com")
如果ie被打开就Ok。

----------------------------------------------------------------------------------------------------------------------------------------------------------

Based on the error, my guess is that watir-classic is failing to install the nokogiri gem. Nokogiri does not currently support Ruby x64 on Windows - see https://github.com/sparklemotion/nokogiri/issues/864.

Two things you could try:

1. Use 32bit Ruby (as suggested in the Nokogiri issue)

2. Use a browser other than IE. By default, Browser.new will start IE using watir-classic. Using one of the other browsers will use watir-webdriver, which I do not believe is dependent on nokogiri.

Example:

require 'watir'
browser = Watir::Browser.new :chrome
browser.goto("http://www.google.com")


你可能感兴趣的:(Ruby&Perl)