Module: Watir::HasWindow

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

Instance Method Summary collapse

Instance Method Details

#original_windowWindow

Returns original window if defined, current window if not See Window#use

Examples:

browser.window(title: 'closeable window').use
browser.original_window.use

Returns:


50
51
52
# File 'lib/watir/has_window.rb', line 50

def original_window
  @original_window ||= window
end

#window(*args, &blk) ⇒ Window

Returns browser window.

Examples:

browser.window(title: 'closeable window')

Returns:


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

def window(*args, &blk)
  win = Window.new self, 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:


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

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

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