Class: Watir::Alert
- Inherits:
-
Object
- Object
- Watir::Alert
- Includes:
- EventuallyPresent
- Defined in:
- lib/watir-webdriver/alert.rb
Instance Method Summary collapse
-
#close ⇒ Object
Closes alert or cancels prompts/confirms.
-
#exists? ⇒ Boolean
(also: #present?)
Returns true if alert, confirm or prompt is present and false otherwise.
-
#initialize(target_locator) ⇒ 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 EventuallyPresent
#wait_until_present, #wait_while_present, #when_present
Constructor Details
#initialize(target_locator) ⇒ Alert
Returns a new instance of Alert.
6 7 8 9 |
# File 'lib/watir-webdriver/alert.rb', line 6 def initialize(target_locator) @target_locator = target_locator @alert = nil end |
Instance Method Details
#close ⇒ Object
Closes alert or cancels prompts/confirms.
49 50 51 52 |
# File 'lib/watir-webdriver/alert.rb', line 49 def close assert_exists @alert.dismiss end |
#exists? ⇒ Boolean Also known as: present?
Returns true if alert, confirm or prompt is present and false otherwise.
77 78 79 80 81 82 |
# File 'lib/watir-webdriver/alert.rb', line 77 def exists? assert_exists true rescue Exception::UnknownObjectException false end |
#ok ⇒ Object
Closes alert or accepts prompts/confirms.
35 36 37 38 |
# File 'lib/watir-webdriver/alert.rb', line 35 def ok assert_exists @alert.accept 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.
89 90 91 |
# File 'lib/watir-webdriver/alert.rb', line 89 def selector_string 'alert' end |
#set(value) ⇒ Object
Enters text to prompt.
64 65 66 67 |
# File 'lib/watir-webdriver/alert.rb', line 64 def set(value) assert_exists @alert.send_keys(value) end |
#text ⇒ String
Returns text of alert.
21 22 23 24 |
# File 'lib/watir-webdriver/alert.rb', line 21 def text assert_exists @alert.text end |