Class: Watir::Window
- Inherits:
-
Object
- Object
- Watir::Window
- Includes:
- ElementExtensions
- Defined in:
- lib/watir-classic/window.rb
Overview
Returned by Browser#window.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#browser ⇒ Browser
Browser of the window.
-
#close ⇒ Object
Close the Window.
- #current? ⇒ Boolean
-
#hwnd ⇒ Fixnum
Handle of the Window.
-
#initialize(main_browser, locators, browser = nil) ⇒ Window
constructor
A new instance of Window.
-
#present? ⇒ Boolean
True when Window browser exists, false otherwise.
-
#title ⇒ String
Title of the Window.
-
#url ⇒ String
Url of the Window.
-
#use { ... } ⇒ Object
Use the window.
Methods included from ElementExtensions
#wait_until_present, #wait_while_present, #when_present
Constructor Details
#initialize(main_browser, locators, browser = nil) ⇒ Window
Returns a new instance of Window.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/watir-classic/window.rb', line 22 def initialize(main_browser, locators, browser=nil) valid_locators = [:title, :url, :hwnd, :index] locators.each_pair do |k, v| raise ArgumentError, "Valid locators are #{valid_locators.join(", ")}" unless valid_locators.include?(k) end @main_browser = main_browser self.class.__main_ie = main_browser.ie @locators = locators @browser = browser end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
89 90 91 |
# File 'lib/watir-classic/window.rb', line 89 def ==(other) browser.hwnd == other.hwnd && browser.html == other.browser.html end |
#browser ⇒ Browser
Returns browser of the window.
44 45 46 47 48 |
# File 'lib/watir-classic/window.rb', line 44 def browser @browser ||= begin Browser.find(@locators.keys.first, @locators.values.first) end end |
#close ⇒ Object
Close the Watir::Window.
41 |
# File 'lib/watir-classic/window.rb', line 41 wrap :url, :title, :hwnd, :close |
#current? ⇒ Boolean
Returns true when Watir::Window is the active Browser instance, false otherwise.
79 80 81 |
# File 'lib/watir-classic/window.rb', line 79 def current? @main_browser.hwnd == browser.hwnd && @main_browser.html == browser.html end |
#hwnd ⇒ Fixnum
Returns handle of the Watir::Window.
41 |
# File 'lib/watir-classic/window.rb', line 41 wrap :url, :title, :hwnd, :close |
#present? ⇒ Boolean
Returns true when Watir::Window browser exists, false otherwise.
84 85 86 87 |
# File 'lib/watir-classic/window.rb', line 84 def present? @browser = nil browser && browser.exists? end |
#title ⇒ String
Returns title of the Watir::Window.
41 |
# File 'lib/watir-classic/window.rb', line 41 wrap :url, :title, :hwnd, :close |
#url ⇒ String
Returns url of the Watir::Window.
41 |
# File 'lib/watir-classic/window.rb', line 41 wrap :url, :title, :hwnd, :close |
#use { ... } ⇒ Object
Use the window.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/watir-classic/window.rb', line 63 def use(&blk) @main_browser.ie = browser.ie if blk begin blk.call ensure @main_browser.ie = self.class.__main_ie # try to find some existing IE when needed @main_browser.ie = Browser._find(:index, 0) unless @main_browser.exists? end end self end |