Sha256: 7dbc0bcdc40317c01671e0fb83e70749be855b2a1395e9d23526ce79a7daf937

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

require 'watir/ie'
# TODO: move this file to watir/contrib

module Watir
  
  class Dialog
    WindowName = 'Windows Internet Explorer'    
    def button(name)
      DialogButton.new(name)
    end
    def close
      # TODO: register autoit before use
      autoit = WIN32OLE.new('AutoItX3.Control')
      autoit.WinClose WindowName, ""
    end
    def exists?
      # TODO: register autoit before use
      autoit = WIN32OLE.new('AutoItX3.Control')
      found = autoit.WinWait(WindowName, "", 1)
      return found == 1
    end 
  end
  
  def dialog
    Dialog.new
  end
  
  class DialogButton
    def initialize(name)
      @name = name
    end
    def click
      # TODO: register autoit before use
      autoit = WIN32OLE.new('AutoItX3.Control')
      autoit.WinWait Dialog::WindowName, "", 1
      name_pattern = Regexp.new "^#{@name}$"
      unless name_pattern =~ autoit.WinGetText(Dialog::WindowName, "")
        raise Watir::Exception::UnknownObjectException
      end
      autoit.Send "{ENTER}"
    end
  end
  
end


Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
watir-1.8.1 lib/watir/dialog.rb
watir-1.8.1.rc1 lib/watir/dialog.rb
watir-1.8.0 lib/watir/dialog.rb
watir-1.8.0.rc1 lib/watir/dialog.rb
watir-1.7.1 lib/watir/dialog.rb
watir-1.7.0 lib/watir/dialog.rb
watir-1.7.0.rc1 lib/watir/dialog.rb
watir-1.6.7 lib/watir/dialog.rb
watir-1.6.7.rc1 lib/watir/dialog.rb
watir-1.6.6 lib/watir/dialog.rb
watir-1.6.6.rc2 lib/watir/dialog.rb
watir-1.6.6.rc1 lib/watir/dialog.rb
watir-1.6.2 lib/watir/dialog.rb