Sha256: 7fd8600b7fcbbe54d776b8ee35607adc2436d5b0cef332d3215597b6ee5fec12

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 Bytes

Contents

# encoding: utf-8
module Watir
  class Alert

    include EventuallyPresent

    def initialize(target_locator)
      @target_locator = target_locator
      @alert = nil
    end

    def text
      assert_exists
      @alert.text
    end

    def ok
      assert_exists
      @alert.accept
    end

    def close
      assert_exists
      @alert.dismiss
    end

    def set(value)
      assert_exists
      @alert.send_keys(value)
    end

    def exists?
      assert_exists
      true
    rescue Exception::UnknownObjectException
      false
    end
    alias_method :present?, :exists?

    def selector_string
      'alert'
    end

    private

    def assert_exists
      @alert = @target_locator.alert
    rescue Selenium::WebDriver::Error::NoAlertPresentError
      raise Exception::UnknownObjectException, 'unable to locate alert'
    end

  end # Alert
end # Watir

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-webdriver-0.6.1 lib/watir-webdriver/alert.rb