我第一次玩 watir,使用这个网站作为指导。我在一个简单的程序(如下)上遇到错误 - 它在第一个非必需行上失败,如图所示。
如果我不运行下面显示的内容,而是删除该行,它会打开一个空的 Firefox 浏览器,但不遵循任何其他说明。它永远不会完成,当我中止它时,我得到一个不同的错误。
我会很感激有关如何进行的建议,并将回应有关更多信息的要求。我在 64 位 Mac 上。谢谢!
简单的程序
require 'rubygems'
require 'watir'
Watir::Browser.default = 'firefox'
browser = Watir::Browser.new
browser.goto("http://www.weather.com")
sleep 5
browser.close
尝试运行程序
matt$ ruby watir_weather.rb
/Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/watir-4.0.2/lib/watir/loader.rb:64: stack level too deep (SystemStackError)
尝试 IRB
matt$ irb
1.9.3-p385 :001 > require 'watir'
=> true
1.9.3-p385 :002 > Watir::Browser.default = 'firefox'
SystemStackError: stack level too deep
from /Users/matt/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/irb/workspace.rb:80
Maybe IRB bug!
1.9.3-p385 :003 > exit
备用程序
require 'rubygems'
require 'watir'
#Watir::Browser.default = 'firefox'
browser = Watir::Browser.new
browser.goto("http://www.weather.com")
sleep 5
browser.close
备用错误
matt$ ruby watir_weather.rb
^C/Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/socket_poller.rb:95:in `sleep': Interrupt
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/socket_poller.rb:95:in `wait'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/socket_poller.rb:88:in `with_timeout'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/socket_poller.rb:23:in `connected?'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:77:in `connect_until_stable'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:37:in `block in launch'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/bridge.rb:20:in `initialize'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/driver.rb:31:in `new'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/driver.rb:31:in `for'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver.rb:67:in `for'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/watir-webdriver-0.6.4/lib/watir-webdriver/browser.rb:46:in `initialize'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/watir-4.0.2/lib/watir/loader.rb:16:in `new'
from /Users/matt/.rvm/gems/ruby-1.9.3-p385/gems/watir-4.0.2/lib/watir/loader.rb:16:in `new'
from watir_weather.rb:5:in `<main>'
宝石(似乎其他人有 ffi 依赖问题)
matt$ gem list
*** LOCAL GEMS ***
actionmailer (3.2.13, 3.2.11)
actionpack (3.2.13, 3.2.11)
activemodel (3.2.13, 3.2.11)
activerecord (3.2.13, 3.2.11)
activeresource (3.2.13, 3.2.11)
activesupport (3.2.13, 3.2.11)
addressable (2.3.2)
annotate (2.5.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bigdecimal (1.1.0)
bloggy (0.2.1)
bootstrap-sass (2.1.0.0)
bootstrap-sass-rails (2.2.2.0)
bourne (1.1.2)
builder (3.0.4)
bundler (1.2.3)
capybara (1.1.2)
childprocess (0.3.8, 0.3.7)
classifier (1.3.3)
cocaine (0.4.2)
coderay (1.0.8)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.1, 1.4.0)
colorator (0.1)
commander (4.1.3)
commonwatir (4.0.0)
devise (2.2.3)
diff-lcs (1.1.3)
directory_watcher (1.4.1)
domain_name (0.5.11)
erubis (2.7.0)
excon (0.16.10)
execjs (1.4.0)
factory_girl (4.1.0)
factory_girl_rails (4.1.0)
faker (1.0.1)
fast-stemmer (1.0.2)
ffi (1.3.1)
heroku (2.35.0)
heroku-api (0.3.7)
highline (1.6.18)
hike (1.2.1)
i18n (0.6.4, 0.6.1)
io-console (0.3)
jekyll (1.0.0)
journey (1.0.4)
jquery-rails (2.2.1, 2.0.2)
json (1.7.7, 1.7.6, 1.5.4)
jwt (0.1.5)
kramdown (0.14.2)
launchy (2.2.0)
liquid (2.5.0)
magic_encoding (0.0.2)
mail (2.5.3, 2.4.4)
maruku (0.6.1)
mechanize (2.6.0)
metaclass (0.0.1)
method_source (0.8.1)
mime-types (1.21, 1.20.1)
minitest (2.5.1)
mocha (0.10.5)
multi_json (1.6.1, 1.5.0)
net-http-digest_auth (1.3)
net-http-persistent (2.8)
netrc (0.7.7)
newrelic_rpm (3.5.8.72)
nokogiri (1.5.9, 1.5.6)
ntlm-http (0.1.1)
orm_adapter (0.4.0)
paperclip (3.4.0)
pg (0.14.1, 0.12.2)
polyglot (0.3.3)
posix-spawn (0.3.6)
pry (0.9.11.4)
pry-rails (0.2.2)
pygments.rb (0.4.2)
rack (1.4.5)
rack-cache (1.2)
rack-contrib (1.1.0)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.11)
railties (3.2.13, 3.2.11)
rake (10.0.3, 0.9.2.2)
rdiscount (2.0.7.2)
rdoc (3.12.2, 3.12.1, 3.9.5)
rest-client (1.6.7)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
rspec-mocks (2.12.2)
rspec-rails (2.12.2)
rubygems-bundler (1.1.0)
rubyzip (0.9.9)
rvm (1.11.3.6)
s3_swf_upload (0.3.2)
safe_yaml (0.7.1)
sass (3.2.7, 3.2.5)
sass-rails (3.2.6)
selenium-webdriver (2.29.0)
shoulda-matchers (1.4.2)
slop (3.4.3)
sprockets (2.2.2)
sqlite3 (1.3.7, 1.3.5)
syntax (1.0.0)
thor (0.17.0)
tilt (1.3.5, 1.3.3)
treetop (1.4.12)
twilio-ruby (3.9.0)
tzinfo (0.3.37, 0.3.35)
uglifier (1.3.0)
unf (0.1.1)
unf_ext (0.0.6)
warden (1.2.1)
watir (4.0.2)
watir-webdriver (0.6.4)
webrick (1.3.1)
webrobots (0.1.1)
websocket (1.0.7)
xpath (0.1.4)
yajl-ruby (1.1.0)