Class: Watir::Alert
- Inherits:
-
Object
- Object
- Watir::Alert
- Defined in:
- lib/watir/alert.rb
Instance Method Summary collapse
-
#close ⇒ Object
Closes alert or cancels prompts/confirms.
-
#exists? ⇒ Boolean
(also: #present?, #exist?)
Returns true if alert, confirm or prompt is present and false otherwise.
-
#initialize(browser) ⇒ Alert
constructor
A new instance of Alert.
-
#ok ⇒ Object
Closes alert or accepts prompts/confirms.
- #selector_string ⇒ Object private
-
#set(value) ⇒ Object
Enters text to prompt.
-
#text ⇒ String
Returns text of alert.
Methods included from Waitable
Constructor Details
#initialize(browser) ⇒ Alert
Returns a new instance of Alert.
8 9 10 11 |
# File 'lib/watir/alert.rb', line 8 def initialize(browser) @browser = browser @alert = nil end |
Instance Method Details
#close ⇒ Object
Closes alert or cancels prompts/confirms.
52 53 54 55 56 |
# File 'lib/watir/alert.rb', line 52 def close wait_for_exists @alert.dismiss @browser.after_hooks.run end |
#exists? ⇒ Boolean Also known as: present?, exist?
Returns true if alert, confirm or prompt is present and false otherwise.
81 82 83 84 85 86 |
# File 'lib/watir/alert.rb', line 81 def exists? assert_exists true rescue UnknownObjectException false end |
#ok ⇒ Object
Closes alert or accepts prompts/confirms.
37 38 39 40 41 |
# File 'lib/watir/alert.rb', line 37 def ok wait_for_exists @alert.accept @browser.after_hooks.run end |
#selector_string ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 |
# File 'lib/watir/alert.rb', line 95 def selector_string 'alert' end |
#set(value) ⇒ Object
Enters text to prompt.
68 69 70 71 |
# File 'lib/watir/alert.rb', line 68 def set(value) wait_for_exists @alert.send_keys(value) end |
#text ⇒ String
Returns text of alert.
23 24 25 26 |
# File 'lib/watir/alert.rb', line 23 def text wait_for_exists @alert.text end |