=begin license --------------------------------------------------------------------------- Copyright (c) 2004 - 2005, Paul Rogers and Bret Pettichord Copyright (c) 2006 - 2007, Bret Pettichord All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the names Paul Rogers, nor Bret Pettichord nor the names of any other contributors to this software may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------- (based on BSD Open Source License) =end require 'watir/win32ole' require 'logger' require 'watir/winClicker' require 'watir/exceptions' require 'watir/utils' require 'watir/close_all' require 'watir/waiter' require 'watir/ie-process' require 'dl/import' require 'dl/struct' require 'Win32API' class String def matches(x) return self == x end end class Regexp def matches(x) return self.match(x) end end class Integer def matches(x) return self == x end end # ARGV needs to be deleted to enable the Test::Unit functionality that grabs # the remaining ARGV as a filter on what tests to run. # Note: this means that watir must be require'd BEFORE test/unit. def command_line_flag(switch) setting = ARGV.include?(switch) ARGV.delete(switch) return setting end # Make Internet Explorer minimize. -b stands for background $HIDE_IE = command_line_flag('-b') # Run fast $FAST_SPEED = command_line_flag('-f') # Eat the -s command line switch (deprecated) command_line_flag('-s') require 'watir/logger' require 'watir/win32' require 'watir/container' require 'watir/locator' require 'watir/page-container' require 'watir/ie' require 'watir/popup' require 'watir/element' require 'watir/frame' require 'watir/modal_dialog' require 'watir/element_collections' require 'watir/form' require 'watir/non_control_elements' require 'watir/input_elements' require 'watir/table' require 'watir/image' require 'watir/link' require 'watir/collections' module Watir include Watir::Exception # Directory containing the watir.rb file @@dir = File.expand_path(File.dirname(__FILE__)) def wait_until(*args) Waiter.wait_until(*args) {yield} end ATTACHER = Waiter.new # Like regular Ruby "until", except that a TimeOutException is raised # if the timeout is exceeded. Timeout is IE.attach_timeout. def self.until_with_timeout # block ATTACHER.timeout = IE.attach_timeout ATTACHER.wait_until { yield } end # Move to Watir::Utils @@autoit = nil def self.autoit unless @@autoit begin @@autoit = WIN32OLE.new('AutoItX3.Control') rescue WIN32OLERuntimeError _register('AutoItX3.dll') @@autoit = WIN32OLE.new('AutoItX3.Control') end end @@autoit end def self._register(dll) system("regsvr32.exe /s " + "#{@@dir}/watir/#{dll}".gsub('/', '\\')) end def self._unregister(dll) system("regsvr32.exe /s /u " + "#{@@dir}/watir/#{dll}".gsub('/', '\\')) end end # why won't this work when placed in the module (where it properly belongs) def _code_that_copies_readonly_array(array, name) "temp = Array.new(#{array.inspect}); #{name}.clear; temp.each {|element| #{name} << element}" end require 'watir/camel_case' require 'watir/bonus-elements'