Class: Watir::ModalDialog

Inherits:
Object
  • Object
show all
Includes:
Container, PageContainer
Defined in:
lib/watir-classic/modal_dialog.rb

Overview

Returned by Container#modal_dialog.

Instance Attribute Summary

Attributes included from Container

#page_container

Instance Method Summary collapse

Methods included from PageContainer

#contains_text, #execute_script, #html, #text, #url

Methods included from Exception

message_for_unable_to_locate

Methods included from Container

#a, #abbr, #address, #alert, #area, #article, #aside, #audio, #b, #base, #bdi, #bdo, #blockquote, #body, #br, #button, #canvas, #caption, #checkbox, #cite, #code, #col, #colgroup, #command, #data, #datalist, #dd, #del, #details, #dfn, #div, #dl, #dt, #element, #em, #embed, #fieldset, #figcaption, #figure, #file_field, #font, #footer, #form, #frame, #frameset, #h1, #h2, #h3, #h4, #h5, #h6, #head, #header, #hgroup, #hidden, #hr, #i, #img, #input, #ins, #kbd, #keygen, #label, #legend, #li, #map, #mark, #menu, #meta, #meter, #modal_dialog, #nav, #noscript, #object, #ol, #optgroup, #option, #output, #p, #param, #pre, #progress, #q, #radio, #rp, #rt, #ruby, #s, #samp, #script, #section, #select, #small, #source, #span, #strong, #style, #sub, #summary, #sup, #table, #tbody, #td, #text_field, #textarea, #tfoot, #th, #thead, #time, #tr, #track, #u, #ul, #var, #video, #wbr

Constructor Details

#initialize(container) ⇒ ModalDialog

Returns a new instance of ModalDialog.



8
9
10
11
# File 'lib/watir-classic/modal_dialog.rb', line 8

def initialize(container)
  set_container container
  @modal = ::RAutomation::Window.new(:hwnd => @container.hwnd).child(:class => 'Internet Explorer_TridentDlgFrame')
end

Instance Method Details

#active?Boolean

Returns true when modal window is active/in focus, false otherwise.

Returns:

  • (Boolean)

    true when modal window is active/in focus, false otherwise.



40
41
42
# File 'lib/watir-classic/modal_dialog.rb', line 40

def active?
  @modal.active?
end

#close(timeout = 5) ⇒ Object

Close the modal dialog.

Parameters:

  • timeout (Fixnum) (defaults to: 5)

    timeout in seconds to wait until modal dialog is successfully closed.



27
28
29
30
31
32
# File 'lib/watir-classic/modal_dialog.rb', line 27

def close(timeout=5)
  return unless exists?
  document.parentWindow.close
  Watir::Wait.until(timeout) {!exists?} rescue nil
  wait
end

#exists?Boolean Also known as: exist?

Returns true when dialog exists, false otherwise.

Returns:

  • (Boolean)

    true when dialog exists, false otherwise.



45
46
47
# File 'lib/watir-classic/modal_dialog.rb', line 45

def exists?
  @modal.exists?
end

#focusObject

Brings the modal dialog to front.



19
20
21
# File 'lib/watir-classic/modal_dialog.rb', line 19

def focus
  @modal.activate
end

#hwndFixnum

Returns window handle of the dialog.

Returns:

  • (Fixnum)

    window handle of the dialog.



35
36
37
# File 'lib/watir-classic/modal_dialog.rb', line 35

def hwnd
  @modal.hwnd
end

#titleString

Returns title of the dialog.

Returns:

  • (String)

    title of the dialog.



14
15
16
# File 'lib/watir-classic/modal_dialog.rb', line 14

def title
  document.title
end