Module: Watir::HasWindow

Included in:
Browser
Defined in:
lib/watir-webdriver/has_window.rb

Instance Method Summary collapse

Instance Method Details

#window(*args, &blk) ⇒ Window

Returns browser window.

Examples:

browser.window(:title => 'closeable window')

Returns:



32
33
34
35
36
37
38
# File 'lib/watir-webdriver/has_window.rb', line 32

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

  win.use(&blk) if block_given?

  win
end

#windows(*args) ⇒ Array<Window>

Returns browser windows array.

Examples:

browser.windows(:title => 'closeable window')

Returns:



13
14
15
16
17
18
19
20
21
# File 'lib/watir-webdriver/has_window.rb', line 13

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