Sha256: 16da8cc7fc63391f7637cf2ddb953012cfe7d246162b5e08467a79ac468563e2

Contents?: true

Size: 979 Bytes

Versions: 16

Compression:

Stored size: 979 Bytes

Contents

# frozen_string_literal: true

Capybara::SpecHelper.spec '#windows', requires: [:windows] do
  before do
    @window = @session.current_window
    @session.visit('/with_windows')
    @session.find(:css, '#openTwoWindows').click

    @session.document.synchronize(3, errors: [Capybara::CapybaraError]) do
      raise Capybara::CapybaraError if @session.windows.size != 3
    end
  end

  after do
    (@session.windows - [@window]).each(&:close)
    @session.switch_to_window(@window)
  end

  it 'should return objects of Capybara::Window class' do
    expect(@session.windows.map { |window| window.instance_of?(Capybara::Window) }).to eq([true] * 3)
  end

  it 'should be able to switch to windows' do
    sleep 1 # give windows enough time to fully load
    titles = @session.windows.map do |window|
      @session.within_window(window) { @session.title }
    end
    expect(titles).to match_array(['With Windows', 'Title of the first popup', 'Title of popup two'])
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
tdiary-5.0.11 vendor/bundle/gems/capybara-3.6.0/lib/capybara/spec/session/window/windows_spec.rb
capybara-3.9.0 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.8.2 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.8.1 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.8.0 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.7.2 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.7.1 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.7.0 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.6.0 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.5.1 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.5.0 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.4.2 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.4.1 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.4.0 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.3.1 lib/capybara/spec/session/window/windows_spec.rb
capybara-3.3.0 lib/capybara/spec/session/window/windows_spec.rb