Class: Watir::Alert
- Inherits:
-
Object
- Object
- Watir::Alert
- Includes:
- ElementExtensions
- Defined in:
- lib/watir-classic/dialogs/alert.rb
Overview
Handle different JavaScript dialogs (alert, prompt and confirm). Returned by Container#alert.
Constant Summary collapse
- WINDOW_TITLES =
JavaScript dialog titles to search for.
['Message from webpage', 'Windows Internet Explorer', 'Microsoft Internet Explorer', /Mensaje de p.*/, 'Explorer User Prompt']
Instance Method Summary collapse
-
#close ⇒ Object
Close the JavaScript dialog.
-
#exists? ⇒ Boolean
(also: #present?)
True when JavaScript dialog exists and is visible, false otherwise.
-
#initialize(container) ⇒ Alert
constructor
A new instance of Alert.
-
#ok ⇒ Object
Press the “OK” button on the JavaScript dialog.
-
#set(text) ⇒ Object
Set the text on the JavaScript prompt dialog.
-
#text ⇒ String
The visible text of the JavaScript dialog.
Methods included from ElementExtensions
#wait_until_present, #wait_while_present, #when_present
Constructor Details
#initialize(container) ⇒ Alert
Returns a new instance of Alert.
13 14 15 |
# File 'lib/watir-classic/dialogs/alert.rb', line 13 def initialize(container) @container = container end |
Instance Method Details
#close ⇒ Object
Close the JavaScript dialog.
25 26 27 28 |
# File 'lib/watir-classic/dialogs/alert.rb', line 25 def close dialog.close wait_until_not_exists end |
#exists? ⇒ Boolean Also known as: present?
Returns true when JavaScript dialog exists and is visible, false otherwise.
18 19 20 |
# File 'lib/watir-classic/dialogs/alert.rb', line 18 def exists? dialog.present? end |
#ok ⇒ Object
Press the “OK” button on the JavaScript dialog.
36 37 38 39 |
# File 'lib/watir-classic/dialogs/alert.rb', line 36 def ok dialog.(:value => "OK").click wait_until_not_exists end |
#set(text) ⇒ Object
Set the text on the JavaScript prompt dialog.
43 44 45 |
# File 'lib/watir-classic/dialogs/alert.rb', line 43 def set(text) dialog.text_field.set text end |
#text ⇒ String
Returns the visible text of the JavaScript dialog.
31 32 33 |
# File 'lib/watir-classic/dialogs/alert.rb', line 31 def text dialog.text end |