Class: Watir::Window
Overview
WindowSwitching
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #close ⇒ Object
- #current? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(driver, id) ⇒ Window
constructor
A new instance of Window.
- #inspect ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #use(&blk) ⇒ Object
Constructor Details
#initialize(driver, id) ⇒ Window
Returns a new instance of Window.
47 48 49 |
# File 'lib/watir-webdriver/window_switching.rb', line 47 def initialize(driver, id) @driver, @id = driver, id end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
55 56 57 58 59 |
# File 'lib/watir-webdriver/window_switching.rb', line 55 def ==(other) return false unless other.kind_of?(self.class) @id == other.id end |
#close ⇒ Object
70 71 72 |
# File 'lib/watir-webdriver/window_switching.rb', line 70 def close use { @driver.close } end |
#current? ⇒ Boolean
66 67 68 |
# File 'lib/watir-webdriver/window_switching.rb', line 66 def current? @driver.window_handle == @id end |
#hash ⇒ Object
62 63 64 |
# File 'lib/watir-webdriver/window_switching.rb', line 62 def hash @id.hash ^ self.class.hash end |
#inspect ⇒ Object
51 52 53 |
# File 'lib/watir-webdriver/window_switching.rb', line 51 def inspect '#<%s:0x%x id=%s>' % [self.class, hash*2, @id.to_s] end |
#title ⇒ Object
74 75 76 77 78 79 |
# File 'lib/watir-webdriver/window_switching.rb', line 74 def title title = nil use { title = @driver.title } title end |
#url ⇒ Object
81 82 83 84 85 86 |
# File 'lib/watir-webdriver/window_switching.rb', line 81 def url url = nil use { url = @driver.current_url } url end |
#use(&blk) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/watir-webdriver/window_switching.rb', line 88 def use(&blk) if current? yield if block_given? return self end @driver.switch_to.window(@id, &blk) self end |