Module: Watir::WindowSwitching

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

Defined Under Namespace

Classes: NoMatchingWindowFoundException

Instance Method Summary collapse

Instance Method Details

#window(*args, &blk) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/watir-webdriver/window_switching.rb', line 17

def window(*args, &blk)
  win = filter_windows(args, windows, :find)

  if win && block_given?
    win.use(&blk)
  end

  win or raise NoMatchingWindowFoundException, args.inspect
end

#windows(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/watir-webdriver/window_switching.rb', line 7

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

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