Sha256: a2648515625285722a49f7b025a7e87951ed84910d4cfb6159a79b4f8d71410b
Contents?: true
Size: 1.88 KB
Versions: 7
Compression:
Stored size: 1.88 KB
Contents
module Watir class Alert include Waitable include Exception def initialize(browser) @browser = browser @alert = nil end # # Returns text of alert. # # @example # browser.alert.text # #=> "ok" # # @return [String] # def text wait_for_exists @alert.text end # # Closes alert or accepts prompts/confirms. # # @example # browser.alert.ok # browser.alert.exists? # #=> false # def ok wait_for_exists @alert.accept @browser.after_hooks.run end # # Closes alert or cancels prompts/confirms. # # @example # browser.alert.close # browser.alert.exists? # #=> false # def close wait_for_exists @alert.dismiss @browser.after_hooks.run end # # Enters text to prompt. # # @example # browser.alert.set "Text for prompt" # browser.alert.ok # # @param [String] value # def set(value) wait_for_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 UnknownObjectException false end alias present? exists? alias exist? exists? # # @api private # @see Watir::Wait # def selector_string 'alert' end private def assert_exists @alert = @browser.driver.switch_to.alert rescue Selenium::WebDriver::Error::NoSuchAlertError raise UnknownObjectException, 'unable to locate alert' end def wait_for_exists wait_until(message: 'waiting for alert', &:exists?) rescue Wait::TimeoutError raise UnknownObjectException, 'unable to locate alert' end end # Alert end # Watir
Version data entries
7 entries across 7 versions & 1 rubygems