Sha256: c6c5a64c7cbaf254f483df1349206178b15f1fb032ae15ccc5deee0dea8a74b0

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 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 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 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.0 lib/watir-webdriver/alert.rb