Sha256: 55ffb41a8ab371aa521e7a66bf78b7f41c877c22390fd5035fdfb5cf4866455c
Contents?: true
Size: 1.62 KB
Versions: 5
Compression:
Stored size: 1.62 KB
Contents
module Watir class Window include ElementExtensions class << self attr_accessor :__main_ie def wrap *meths meths.each do |meth| define_method meth do result = nil use {result = browser.send(meth)} result end end end end def initialize(main_browser, locators, browser=nil, &blk) 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 wrap :url, :title, :hwnd, :close def browser @browser ||= begin IE.find(@locators.keys.first, @locators.values.first) end end 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 = IE._find(:index, 0) unless @main_browser.exists? end end self end def current? @main_browser.hwnd == browser.hwnd && @main_browser.html == browser.html end def ==(other) browser.hwnd == other.hwnd && browser.html == other.browser.html end alias_method :eql?, :== def present? @browser = nil browser && browser.exists? end end end
Version data entries
5 entries across 5 versions & 1 rubygems