Sha256: 277027674643c918ad4bef64242d5a26d5d6cb3ee8b7d5d4c59200ce6b85d013

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

require 'watir'
# 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

5 entries across 5 versions & 1 rubygems

Version Path
watir-1.5.4 watir/dialog.rb
watir-1.5.2 watir/dialog.rb
watir-1.5.3 watir/dialog.rb
watir-1.5.5 watir/dialog.rb
watir-1.5.6 watir/dialog.rb