Sha256: d53190d402ca9880a4b554506a00cb820ed3063b9fb642cdd5738bd5cd2146a2

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

module Watir

  class JavascriptDialog
    WINDOW_TITLES = ['Message from webpage', 'Windows Internet Explorer','Microsoft Internet Explorer']

    attr_accessor :timeout

    def initialize(opts={})
      @opts = opts
      @timeout = 30
    end

    def exists?
      javascript_dialog_window.exists?
    end

    def button(value)
      javascript_dialog_window.button(:value => value)
    end

    def close
      javascript_dialog_window.close
    end

    def text
      javascript_dialog_window.text
    end

    def javascript_dialog_window
      return @window if @window
      begin
        original_timeout = RAutomation::Window.wait_timeout
        RAutomation::Window.wait_timeout = @timeout
        ::RAutomation::Window.new(:title => @opts[:title] || /^(#{WINDOW_TITLES.join('|')})$/)
      ensure
        RAutomation::Window.wait_timeout = original_timeout
      end
      @window
    end

  end
end





Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-1.9.0.rc2 lib/watir/dialogs/javascript.rb
watir-1.9.0.rc1 lib/watir/dialogs/javascript.rb