Class: Prof::OpsManager::WebAppInternals::Page::Form

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Form

Returns a new instance of Form.



24
25
26
27
# File 'lib/prof/ops_manager/web_app_internals/page/form.rb', line 24

def initialize(opts = {})
  @page         = opts.fetch(:page)
  @form_element = opts.fetch(:form_element)
end

Instance Method Details

#update(config = {}) {|_self, page| ... } ⇒ Object

Yields:

  • (_self, page)

Yield Parameters:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/prof/ops_manager/web_app_internals/page/form.rb', line 29

def update(config = {}, &_block)
  case config
  when Array
    update_list(config)
  when Hash, FormFields
    raise "Add button on page #{page.current_url}, maybe you should update a list?" if add_button

    update_fields(config)
  else
    raise "Unrecognised config #{config.inspect}"
  end

  yield self, page if block_given?

  form_element.click_on 'Save'

  # raise "Failed to save, the server 500ed" if page.status_code.to_i >= 500
  raise "Failed to save, no success message. #{error_message}" unless success?
end