Class: Vapir::IE::ModalDialog
- Inherits:
-
Object
- Object
- Vapir::IE::ModalDialog
- Includes:
- ModalDialog
- Defined in:
- lib/vapir-ie/modal_dialog.rb
Instance Method Summary collapse
- #click_button(button_text, options = {}) ⇒ Object
- #close ⇒ Object
- #document ⇒ Object
- #exists? ⇒ Boolean
- #hwnd ⇒ Object
- #locate ⇒ Object
- #set_text_field(value) ⇒ Object
- #text ⇒ Object
- #win_window ⇒ Object
Instance Method Details
#click_button(button_text, options = {}) ⇒ Object
44 45 46 47 48 |
# File 'lib/vapir-ie/modal_dialog.rb', line 44 def (, ={}) assert_exists =(, :timeout => ModalDialog::DEFAULT_TIMEOUT) @modal_window.(, [:timeout]) end |
#close ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vapir-ie/modal_dialog.rb', line 50 def close if (document=IE::ModalDialogDocument.new(self, :error => false, :timeout => 0)) && document.exists? document.close else @modal_window.send_close! end ::Waiter.try_for(ModalDialog::DEFAULT_TIMEOUT, :exception => Vapir::Exception::WindowException.new("The modal window failed to close")) do !exists? end end |
#document ⇒ Object
69 70 71 72 |
# File 'lib/vapir-ie/modal_dialog.rb', line 69 def document assert_exists IE::ModalDialogDocument.new(self) end |
#exists? ⇒ Boolean
28 29 30 |
# File 'lib/vapir-ie/modal_dialog.rb', line 28 def exists? @modal_window && @modal_window.exists? end |
#hwnd ⇒ Object
61 62 63 64 |
# File 'lib/vapir-ie/modal_dialog.rb', line 61 def hwnd assert_exists @modal_window.hwnd end |
#locate ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vapir-ie/modal_dialog.rb', line 7 def locate @modal_window=@browser.win_window.enabled_popup || begin # IE9 modal dialogs aren't modal to the actual browser window. instead it creates some # other window with class_name="Alternate Modal Top Most" and makes the modal dialog modal # to that thing instead. this has the same text (title) as the browser window but that # is the only relationship I have found so far to the browser window. I'd like to use a # stronger relationship than that, but, it'll have to do. matching_windows = WinWindow::All.select do |win| win.parent && win.parent.class_name == "Alternate Modal Top Most" && win.parent.text == @browser.win_window.text end case matching_windows.size when 0 nil when 1 matching_windows.first else raise Vapir::Exception::WindowException, "found multiple windows that looked like popups: #{matching_windows.inspect}" end end end |
#set_text_field(value) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/vapir-ie/modal_dialog.rb', line 37 def set_text_field(value) assert_exists edit_field=@modal_window.children.detect{|child| child.class_name=='Edit'} || (raise "No Edit field in the popup!") edit_field.send_set_text!(value) value end |
#text ⇒ Object
32 33 34 35 |
# File 'lib/vapir-ie/modal_dialog.rb', line 32 def text assert_exists @modal_window.children.select{|child| child.class_name.downcase=='static' && child.text!=''}.map{|c| c.text }.join(' ') end |
#win_window ⇒ Object
65 66 67 |
# File 'lib/vapir-ie/modal_dialog.rb', line 65 def win_window @modal_window end |