lib/watir/ie-class.rb in watir-1.8.1 vs lib/watir/ie-class.rb in watir-1.9.0.rc1

- old
+ new

@@ -247,11 +247,25 @@ ie_browsers.each do |ie| yield ie end end - # return internet explorer instance as specified. if none is found, + def self.version + begin + require 'win32/registry' + ::Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\Microsoft\\Internet Explorer") do |ie_key| + ie_key.read('Version').last + end + # OR: ::WIN32OLE.new("WScript.Shell").RegRead("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\Version") + end + end + + def self.version_parts + version.split('.') + end + + # return internet explorer instance as specified. if none is found, # return nil. # arguments: # :url, url -- the URL of the IE browser window # :title, title -- the title of the browser page # :hwnd, hwnd -- the window handle of the browser window. @@ -411,46 +425,56 @@ end end # Maximize the window (expands to fill the screen) def maximize - set_window_state :SW_MAXIMIZE + rautomation.maximize end # Minimize the window (appears as icon on taskbar) def minimize - set_window_state :SW_MINIMIZE + rautomation.minimize end + def minimized? + rautomation.minimized? + end + # Restore the window (after minimizing or maximizing) def restore - set_window_state :SW_RESTORE + rautomation.restore end # Make the window come to the front - def bring_to_front - autoit.WinActivate title, '' + def activate + rautomation.activate end + alias :bring_to_front :activate - def front? - 1 == autoit.WinActive(title, '') + def active? + rautomation.active? end + alias :front? :active? - private - def set_window_state(state) - autoit.WinSetState title, '', autoit.send(state) + def rautomation + @rautomation ||= ::RAutomation::Window.new(:hwnd => hwnd) + @rautomation end + def autoit - Watir::autoit + raise NotImplementedError, 'Watir no longer uses AutoIT. ' << + 'If you need this functionality you can downgrade to v1.8.1 ' << + 'or update your scripts to use ie.rautomation. ' << + 'Please refer to https://github.com/jarmo/RAutomation' end - public - # Send key events to IE window. - # See http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm - # for complete documentation on keys supported and syntax. + # Activates the window and sends keys to it. + # + # Refer to MSDN documentation at http://msdn.microsoft.com/en-us/library/dd375731(v=VS.85).aspx + # for the keycodes. + # @see RAutomation::Window#send_keys def send_keys(key_string) - autoit.WinActivate title - autoit.Send key_string + rautomation.send_keys key_string end def dir return File.expand_path(File.dirname(__FILE__)) end