Class: Vapir::IE::ModalDialog

Inherits:
Object
  • Object
show all
Includes:
ModalDialog
Defined in:
lib/vapir-ie/modal_dialog.rb

Instance Method Summary collapse

Instance Method Details

#click_button(button_text, options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/vapir-ie/modal_dialog.rb', line 29

def click_button(button_text, options={})
  assert_exists
  options=handle_options(options, :timeout => ModalDialog::DEFAULT_TIMEOUT)
  @modal_window.click_child_button_try_for!(button_text, options[:timeout])
end

#closeObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/vapir-ie/modal_dialog.rb', line 35

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

#documentObject



54
55
56
57
# File 'lib/vapir-ie/modal_dialog.rb', line 54

def document
  assert_exists
  IE::ModalDialogDocument.new(self)
end

#exists?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/vapir-ie/modal_dialog.rb', line 13

def exists?
  @modal_window && @modal_window.exists?
end

#hwndObject



46
47
48
49
# File 'lib/vapir-ie/modal_dialog.rb', line 46

def hwnd
  assert_exists
  @modal_window.hwnd
end

#locateObject



9
10
11
# File 'lib/vapir-ie/modal_dialog.rb', line 9

def locate
  @modal_window=@browser.win_window.enabled_popup
end

#set_text_field(value) ⇒ Object



22
23
24
25
26
27
# File 'lib/vapir-ie/modal_dialog.rb', line 22

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

#textObject



17
18
19
20
# File 'lib/vapir-ie/modal_dialog.rb', line 17

def text
  assert_exists
  @modal_window.children.select{|child| child.class_name.downcase=='static' && child.text!=''}.map{|c| c.text }.join(' ')
end

#win_windowObject



50
51
52
# File 'lib/vapir-ie/modal_dialog.rb', line 50

def win_window
  @modal_window
end