Sha256: 8cfdfa6c0152127e66b1267b0bb3b15cb517a6d25c23cb4763f681701a5f78b1

Contents?: true

Size: 1.3 KB

Versions: 85

Compression:

Stored size: 1.3 KB

Contents

module OpsManagerUiDrivers
  module Version15
    class JobNetworkMappingHelper
      PRODUCT_NETWORK_FIELD_NAME = 'product_network_assignment'

      def initialize(product_name:, browser:)
        @product_name = product_name
        @browser = browser
      end

      def assign_product_to_network(network)
        open_form
        browser.find_field(PRODUCT_NETWORK_FIELD_NAME).find(:option, text: network).select_option
        save_form
      end

      def product_network
        open_form
        selected_options = browser.find_field(PRODUCT_NETWORK_FIELD_NAME).all('option[selected]')
        raise ArgumentError, "#{PRODUCT_NETWORK_FIELD_NAME} not selected" if selected_options.empty?
        selected_options.first.text
      end

      private

      attr_reader :product_name, :browser

      def open_form
        browser.visit '/'
        browser.click_on "show-#{product_name}-configure-action"
        browser.click_on "show-#{product_name}-network-assignment-action"
      end

      def save_form
        browser.click_on 'Save'

        unless browser.has_css?('.flash-message.success')
          if browser.has_css?('.flash-message.error')
            raise browser.find('.flash-message.error').text
          else
            raise 'unexpected failure'
          end
        end
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
ops_manager_ui_drivers-1.8.3 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.28.1 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.28.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.27.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.26.1 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.26.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.25.1 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.25.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.24.4 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.24.3 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.24.2 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.24.1 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.24.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.23.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.22.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.21.1 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.21.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.20.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.19.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb
ops_manager_ui_drivers-1.18.0 lib/ops_manager_ui_drivers/version15/job_network_mapping_helper.rb