Watir-Rails`浏览器窗口已关闭,没有关闭任何内容

时间:2016-03-10 16:06:34

标签: ruby watir watir-webdriver

我开始新鲜的watir-rails。我找不到Window的例外。

  

的Watir ::异常:: NoMatchingWindowFoundException:          浏览器窗口关闭了   /Users/aaron/.rvm/gems/ruby-2.1.6/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:344:在`assert_exists'

我不确定这是否应该发生,但是当我启动一个新驱动程序时,有14个窗口属于该驱动程序,但它们都不存在。

[2] pry(#<RSpec::ExampleGroups::PokitdokPDPC::Clinic>)> browser.windows
[
  [ 0] #<Watir::Window:0x242074a821d6075a located=true>,
  [ 1] #<Watir::Window:0x5521d3908d99909a located=true>,
  [ 2] #<Watir::Window:0x..fa544e5b1f07a764e located=true>,
  [ 3] #<Watir::Window:0x..feb72338121a19c86 located=true>,
  [ 4] #<Watir::Window:0x2cc412dc5e76463e located=true>,
  [ 5] #<Watir::Window:0x..f8644fa95ef4e22ac located=true>,
  [ 6] #<Watir::Window:0x..f8d8c0e47ffcfc502 located=true>,
  [ 7] #<Watir::Window:0x9a30ded69ef370e located=true>,
  [ 8] #<Watir::Window:0x..fe4f2d355d2301ebc located=true>,
  [ 9] #<Watir::Window:0x..fccfaa137adda58cc located=true>,
  [10] #<Watir::Window:0x6f6f80943b132490 located=true>,
  [11] #<Watir::Window:0x32677c64365802fc located=true>,
  [12] #<Watir::Window:0x..fed6bcc7b81d099ce located=true>,
  [13] #<Watir::Window:0x501561edeacf8b50 located=true>
]
[3] pry(#<RSpec::ExampleGroups::PokitdokPDPC::Clinic>)> windows = browser.windows.find_all{|w| w.present?}
[]

我的代码:

require "spec_helper"

describe "Registration", type: :feature do

  it 'allows a user to sign up' do
    Watir.driver = :webdriver
    browser = Watir::Browser.new :firefox

    browser.goto root_path #Navigates correctly to root_path
    browser.link(text: 'Register').click #Throws window not found
  end
end

1 个答案:

答案 0 :(得分:0)

我跟着this并且只做了第1步 - 创建了注册表中的密钥 - 并且工作正常。