Module: Watir::HasWindow
- Included in:
- Browser
- Defined in:
- lib/watir/has_window.rb
Instance Attribute Summary collapse
-
#original_window ⇒ Window
Returns original window if defined, current window if not See Window#use.
Instance Method Summary collapse
-
#switch_window ⇒ Window
Waits for and returns second window if present See Window#use.
-
#window(opts = {}, &blk) ⇒ Window
Returns browser window.
-
#windows(opts = {}) ⇒ Array<Window>
Returns browser windows array.
Instance Attribute Details
#original_window ⇒ Window
Returns original window if defined, current window if not See Window#use
48 49 50 |
# File 'lib/watir/has_window.rb', line 48 def original_window @original_window ||= window end |
Instance Method Details
#switch_window ⇒ Window
Waits for and returns second window if present See Window#use
62 63 64 65 66 67 68 69 70 |
# File 'lib/watir/has_window.rb', line 62 def switch_window current_window = window wins = windows wait_until { (wins = windows) && wins.size > 1 } if wins.size == 1 raise StandardError, 'Unable to determine which window to switch to' if wins.size > 2 wins.find { |w| w != current_window }.use window end |
#window(opts = {}, &blk) ⇒ Window
Returns browser window.
29 30 31 32 33 34 35 |
# File 'lib/watir/has_window.rb', line 29 def window(opts = {}, &blk) win = Window.new self, opts win.use(&blk) if blk win end |
#windows(opts = {}) ⇒ Array<Window>
Returns browser windows array.
16 17 18 |
# File 'lib/watir/has_window.rb', line 16 def windows(opts = {}) WindowCollection.new self, opts end |