部署linux(ubuntu11.04) 中ruby&watir运行环境

部署linux(ubuntu11.04) 中ruby&watir运行环境

  Ubuntu  Linux 11.04 ruby&watir运行环境:

Step 1.Ruby安装

$sudo apt-get install ruby

查看是否安装成功:

$ ruby -v

ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]



Step 2. RubyGems安装(管理ruby包)

$sudo apt-get install rubygems1.8

查看是否安装成功:

$ gem -v

1.3.7

Step 3.更新gem update

如果直接使用命令sudo gem update –system,则会报错如下:

$ gem update –system

ERROR: While executing gem ... (RuntimeError)

gem update --system is disabled on Debian, because it will

overwrite the content of the rubygems Debian package......

解决方法:
$sudo gem install rubygems-update
Successfully installed rubygems-update-1.3.7
再执行update_rubygems更新命令:
$sudo /var/lib/gems/1.8/bin/update_rubygems
RubyGems installed the following executables:/usr/bin/gem1.8

Step4.watir-webdriver安装(支持iefirefox,chromeand Opera)
$sudo gem install watir-webdriver --no-ri --no-rdoc
(...)
Successfully installed watir-webdriver-0.2.8
4 gems installed
Let's check if it can drive Firefox :

wdd@ubuntu:~$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'watir-webdriver'
=> true
irb(main):003:0>browser = Watir::Browser.new :ff
/usr/lib/ruby/gems/1.8/gems/selenium-webdriver- 2.13.0/lib/selenium/webdriver/common/platform.rb:129: warning: Insecure world writable dir /opt in PATH, mode 040777=> #<Watir::Browser:0x..fb6fb4f80 url="about:blank" title="">
irb(main):004:0> browser.goto('www.google.com')
=> "http://www.google.com.hk/"

Note:
If you want to use chrome,you should install chrome first.You do this:
browser = Watir::Browser.new :chrome
if you use ie or Opera, do this:
browser = Watir::Browser.new :ie
browser = Watir::Browser.new :opera
Start your script!

你可能感兴趣的:(部署linux(ubuntu11.04) 中ruby&watir运行环境)