Sha256: 3bff6438b3d04cc037559609bc830a79e85203d4b5bf53607dd8df798013a0fc

Contents?: true

Size: 756 Bytes

Versions: 14

Compression:

Stored size: 756 Bytes

Contents

module Watir
  module HasWindow
    def windows(*args)
      all = @driver.window_handles.map { |handle| Window.new(@driver, :handle => handle) }

      if args.empty?
        all
      else
        filter_windows extract_selector(args), all
      end
    end

    def window(*args, &blk)
      win = Window.new @driver, extract_selector(args)

      win.use(&blk) if block_given?

      win
    end

    private

    def filter_windows(selector, windows)
      unless selector.keys.all? { |k| [:title, :url].include? k }
        raise ArgumentError, "invalid window selector: #{selector.inspect}"
      end

      windows.select do |win|
        selector.all? { |key, value| value === win.send(key) }
      end
    end
  end # WindowSwitching
end # Watir

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
watir-webdriver-0.6.1 lib/watir-webdriver/has_window.rb
watir-webdriver-0.6.0 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.8 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.7 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.6 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.5 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.4 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.3 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.2 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.1 lib/watir-webdriver/has_window.rb
watir-webdriver-0.5.0 lib/watir-webdriver/has_window.rb
watir-webdriver-0.4.1 lib/watir-webdriver/has_window.rb
watir-webdriver-0.4.0 lib/watir-webdriver/has_window.rb
watir-webdriver-0.3.9 lib/watir-webdriver/has_window.rb