step1:下载相关资源
主要资源:rubyinstaller-1.9.2-p290.exe (为1.9.2版本即可)
备用资源:rubygems-update-1.8.24.gem(最新版本即可)
http://code.google.com/p/selenium/downloads/list
主要资源:IEDriverServer_Win32_2.25.3.zip(最新版本即可)
step2:安装ruby
运行rubyinstaller-1.9.2-p290.exe,安装界面勾选项全选。命令窗口验证如下,安装成功。
C:\>ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
C:\>gem -v
1.7.2
step3:升级gem
如果网络正常可在线升级;否则,用备用资源rubygems-update-1.8.x.gem本地升级。
在线升级:
C:\>gem update --system
Updating rubygems-update
Fetching: rubygems-update-1.8.24.gem (100%)
Successfully installed rubygems-update-1.8.24
Installing RubyGems 1.8.24
RubyGems 1.8.24 installed
== 1.8.24 / 2012-04-27
* 1 bug fix:
* Install the .pem files properly. Fixes #320
* Remove OpenSSL dependency from the http code path
-------------------------------------------------------
RubyGems installed the following executables:
C:/Ruby192/bin/gem
RubyGems system software updated
C:\>gem -v
1.8.24
step4:安装watir-webdriver
在线安装,若本地安装需下载相关gem包。
C:\>gem install watir-webdriver
Fetching: multi_json-1.3.6.gem (100%)
Fetching: rubyzip-0.9.9.gem (100%)
Fetching: ffi-1.1.5-x86-mingw32.gem (100%)
Fetching: childprocess-0.3.6.gem (100%)
Fetching: addressable-2.3.2.gem (100%)
Fetching: libwebsocket-0.1.5.gem (100%)
Fetching: selenium-webdriver-2.25.0.gem (100%)
Fetching: watir-webdriver-0.6.1.gem (100%)
Successfully installed multi_json-1.3.6
Successfully installed rubyzip-0.9.9
Successfully installed ffi-1.1.5-x86-mingw32
Successfully installed childprocess-0.3.6
Successfully installed addressable-2.3.2
Successfully installed libwebsocket-0.1.5
Successfully installed selenium-webdriver-2.25.0
Successfully installed watir-webdriver-0.6.1
8 gems installed
Installing ri documentation for multi_json-1.3.6...
Installing ri documentation for rubyzip-0.9.9...
Installing ri documentation for ffi-1.1.5-x86-mingw32...
Installing ri documentation for childprocess-0.3.6...
Installing ri documentation for addressable-2.3.2...
Installing ri documentation for libwebsocket-0.1.5...
Installing ri documentation for selenium-webdriver-2.25.0...
Installing ri documentation for watir-webdriver-0.6.1...
Installing RDoc documentation for multi_json-1.3.6...
Installing RDoc documentation for rubyzip-0.9.9...
Installing RDoc documentation for ffi-1.1.5-x86-mingw32...
Installing RDoc documentation for childprocess-0.3.6...
Installing RDoc documentation for addressable-2.3.2...
Installing RDoc documentation for libwebsocket-0.1.5...
Installing RDoc documentation for selenium-webdriver-2.25.0...
Installing RDoc documentation for watir-webdriver-0.6.1...
C:\>gem list watir
*** LOCAL GEMS ***
watir-webdriver (0.6.1)
C:\>
step5:安装IEDriverServer
解压IEDriverServer_Win32_2.25.3.zip,将IEDriverServer.exe放置ruby安装路径: C:\Ruby192\bin(视自己安装路径而定)
step6:验证watir-webdriver
C:\>irb
irb(main):001:0> require 'watir-webdriver'
=> true
irb(main):002:0> Watir::Browser.new :ie
Started InternetExplorerDriver server (32-bit)
2.25.3.0
Listening on port 5555
=> #<Watir::Browser:0x535c826e url="http://localhost:5555/" title="WebDriver">
irb(main):003:0>
提示:红色部分为手工输入命令,注意空格!!