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.a(:id => "open_new_window").click
browser.window(:title => "new")

Returns:



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

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.a(:id => "open_new_window").click
browser.windows(:title => "new")

Returns:



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

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