Class: Prof::OpsManager::WebAppInternals::Page::Modal

Inherits:
Object
  • Object
show all
Defined in:
lib/prof/ops_manager/web_app_internals/page/modal.rb

Constant Summary collapse

ModalStillPresent =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(page:) ⇒ Modal

Returns a new instance of Modal.



19
20
21
# File 'lib/prof/ops_manager/web_app_internals/page/modal.rb', line 19

def initialize(page:)
  @page = page
end

Instance Method Details

#confirmObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/prof/ops_manager/web_app_internals/page/modal.rb', line 23

def confirm
  # We have spent a long time trying to debug unreliable clicking of confirm
  # in both Selenium and Poltegeist. The box is animated which we think is causing
  # issues with where the browser is clicking. A sleep will resolve this, and has
  # lowest complexity.
  Kernel.sleep(3)

  confirm_button.click

  await_modal_disappearance!
  true
end

#failure?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/prof/ops_manager/web_app_internals/page/modal.rb', line 40

def failure?
  /failure/ =~ modal['id']
end

#messageObject



44
45
46
# File 'lib/prof/ops_manager/web_app_internals/page/modal.rb', line 44

def message
  modal.find('.modal-body').text
end

#present?Boolean

Returns:

  • (Boolean)


48
49
50
51
52
# File 'lib/prof/ops_manager/web_app_internals/page/modal.rb', line 48

def present?
  page.all(modal_css_selector).any? || page.all('.modal-backdrop').any?
rescue Capybara::Poltergeist::ObsoleteNode
  false
end

#success?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/prof/ops_manager/web_app_internals/page/modal.rb', line 36

def success?
  /success/ =~ modal['id']
end