watir/WindowHelper.rb in watir-1.4.1 vs watir/WindowHelper.rb in watir-1.5.2

- old
+ new

@@ -1,28 +1,30 @@ -require 'win32ole' +require 'watir/win32ole' +require 'watir' # for Watir.autoit class WindowHelper - def initialize( ) - @autoit = WIN32OLE.new('AutoItX3.Control') + @@ie_window_name = "Windows Internet Explorer" + def initialize() + @autoit = Watir.autoit end - def push_alert_button() - @autoit.WinWait "Microsoft Internet Explorer", "" + def push_alert_button + @autoit.WinWait @@ie_window_name, "" @autoit.Send "{ENTER}" end - def push_confirm_button_ok() - @autoit.WinWait "Microsoft Internet Explorer", "" + def push_confirm_button_ok + @autoit.WinWait @@ie_window_name, "" @autoit.Send "{ENTER}" end - def push_confirm_button_cancel() - @autoit.WinWait "Microsoft Internet Explorer", "" + def push_confirm_button_cancel + @autoit.WinWait @@ie_window_name, "" @autoit.Send "{ESCAPE}" end - def push_security_alert_yes() + def push_security_alert_yes @autoit.WinWait "Security Alert", "" @autoit.Send "{TAB}" @autoit.Send "{TAB}" @autoit.Send "{SPACE}" end @@ -35,10 +37,10 @@ @autoit.Send "{ENTER}" end def WindowHelper.check_autoit_installed begin - WIN32OLE.new('AutoItX3.Control') + Watir.autoit rescue raise Watir::Exception::WatirException, "The AutoIt dll must be correctly registered for this feature to work properly" end end end