Sha256: 6c70902ba3717f7cd214d767a562b408f1f732f0815c019392814f693a34a626

Contents?: true

Size: 937 Bytes

Versions: 4

Compression:

Stored size: 937 Bytes

Contents

module Watir
  class Alert
    include ElementExtensions

    WINDOW_TITLES = ['Message from webpage', 'Windows Internet Explorer', 'Microsoft Internet Explorer', /Mensaje de p.*/, "Explorer User Prompt"]

    def initialize(container)
      @container = container
    end

    def exists?
      dialog.present?
    end

    alias_method :present?, :exists?

    def close
      dialog.close
      wait_until_not_exists
    end

    def text
      dialog.text
    end

    def ok
      dialog.button(:value => "OK").click
      wait_until_not_exists
    end

    def set(text)
      dialog.text_field.set text
    end

    private 

    def dialog
      @window ||= RAutomation::Window.new(:hwnd => @container.hwnd).child(:title => /^(#{WINDOW_TITLES.join('|')})$/)
    end

    def wait_until_not_exists
      Wait.until(3) {!exists?}
      @container.page_container.wait
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
watir-classic-3.3.0 lib/watir-classic/dialogs/alert.rb
watir-classic-3.2.0 lib/watir-classic/dialogs/alert.rb
watir-classic-3.2.0.rc1 lib/watir-classic/dialogs/alert.rb
watir-classic-3.1.0 lib/watir-classic/dialogs/alert.rb