Sha256: 5ebe96367d3a567f404ebe304d741e8957ca4fc8b3d5a433769e534f6c68c850

Contents?: true

Size: 1.43 KB

Versions: 39

Compression:

Stored size: 1.43 KB

Contents

module OpsManagerUiDrivers
  module Version16
    module BoshProductSections
      class BoshProductFormSection
        def initialize(browser, field_prefix)
          @browser = browser
          @field_prefix = field_prefix
        end

        def open_form(form_name)
          @browser.visit '/'
          @browser.click_on 'show-p-bosh-configure-action'
          @browser.click_on "show-#{form_name}-action"
        end

        def save_form(allowed_errors=[])
          @browser.click_on 'Save'
          !@browser.all('.flash-message.success').empty? || only_has_allowed_verification_errors(allowed_errors)
        end

        def set_fields(fields)
          fields.each do |field, value|
            set_field(field, value)
          end
        end

        private

        def only_has_allowed_verification_errors(allowed_errors)
          flash_errors = @browser.all('.flash-message.error')
          unexpected_errors = []

          if flash_errors.any?
            unexpected_errors = flash_errors.reject do |error|
              allowed_errors.select do |expected_error|
                error.text =~ expected_error
              end.any?
            end
          end

          unexpected_errors.empty?
        end

        def set_field(field, value)
          last_field(field).set(value)
        end

        def last_field(field)
          @browser.all(:field, "#{@field_prefix}[#{field}]").last
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
ops_manager_ui_drivers-2.42.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.41.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.40.1 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.40.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.39.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.38.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.37.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.36.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.35.2 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.35.1 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.35.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.34.1 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.34.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.33.1 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.33.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.32.1 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.32.0 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.31.3 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.31.2 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb
ops_manager_ui_drivers-2.31.1 lib/ops_manager_ui_drivers/version16/bosh_product_sections/bosh_product_form_section.rb