Sha256: 9aa277f211863e1518dd8ba2c10e23b2086fe946a0e92f9b64173f38b8a37e6d
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
# encoding: utf-8 module Watir class Alert include EventuallyPresent def initialize(target_locator) @target_locator = target_locator @alert = nil end # # Returns text of alert. # # @example # browser.alert.text # #=> "ok" # # @return [String] # def text assert_exists @alert.text end # # Closes alert or accepts prompts/confirms. # # @example # browser.alert.ok # browser.alert.exists? # #=> false # def ok assert_exists @alert.accept end # # Closes alert or cancels prompts/confirms. # # @example # browser.alert.close # browser.alert.exists? # #=> false # def close assert_exists @alert.dismiss end # # Enters text to prompt. # # @example # browser.alert.set "Text for prompt" # browser.alert.ok # # @param [String] value # def set(value) assert_exists @alert.send_keys(value) end # # Returns true if alert, confirm or prompt is present and false otherwise. # # @example # browser.alert.exists? # #=> true # def exists? assert_exists true rescue Exception::UnknownObjectException false end alias_method :present?, :exists? # # @api private # 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.7.0 | lib/watir-webdriver/alert.rb |