Sha256: b3470ec028435fa58d6ec7b2c2c4fc16004d9a3fa4df459d6ec92468f2a6ea93

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

class WinClicker
  def initialize
    raise NotImplementedError, 'Watir no longer supports WinClicker. Please use click_no_wait and the javascript_dialog method.'
  end
end

module Watir
  class ModalDialog
    include Container
    include PageContainer
    include Win32

    def initialize(container)
      set_container container
      @modal = ::RAutomation::Window.new(:hwnd=>@container.hwnd).child(:class => 'Internet Explorer_TridentDlgFrame')
    end

    def locate
      @modal.wait_until_present rescue raise NoMatchingWindowFoundException

      intUnknown = 0
      Watir::until_with_timeout do
        intPointer = " " * 4 # will contain the int value of the IUnknown*
        GetUnknown.call(hwnd, intPointer)
        intArray = intPointer.unpack('L')
        intUnknown = intArray.first
        intUnknown > 0
      end
      
      WIN32OLE.connect_unknown(intUnknown)
    rescue NoMatchingWindowFoundException, Wait::TimeoutError
      raise NoMatchingWindowFoundException,
        "Unable to attach to Modal Window."
    end

    alias_method :document, :locate

    def title
      document.title
    end

    def close(timeout=5)
      return unless exists?
      document.parentWindow.close
      Watir::Wait.until(timeout) {!exists?} rescue nil
      wait
    end

    def attach_command
      "Watir::IE.find(:hwnd, #{@container.hwnd}).modal_dialog"
    end

    def wait(no_sleep=false)
      @container.page_container.wait unless exists?
    end

    def hwnd
      @modal.hwnd
    end

    def active?
      @modal.active?
    end

    def exists?
      @modal.exists?
    end

    alias_method :exist?, :exists?

  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
watir-classic-3.0.0 lib/watir-classic/modal_dialog.rb
watir-3.0.0.rc3 lib/watir/modal_dialog.rb