Sha256: 0625e3baa3e261a67bba6fa7c827f718405a741b6f7b7b6267a84f75a3f8c09e

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

module OpsManagerUiDrivers
  module Version15
    class Setup
      def initialize(browser: nil)
        @browser = browser
      end

      def setup_and_login(user:, password:)
        browser.visit '/setup'
        browser.fill_in 'user[user_name]', with: user, wait: 4
        browser.fill_in 'user[password]', with: password
        browser.fill_in 'user[password_confirmation]', with: password
        browser.check 'user_eula_accepted'
        browser.click_on 'create-user-action'
      end

      def login(user: nil, password: nil)
        browser.visit '/login'
        browser.fill_in 'login[user_name]', with: user, wait: 4
        browser.fill_in 'login[password]', with: password
        browser.click_on 'login-action'

        unless browser.first('#main-page-marker')
          fail RuntimeError.new("failed to log in as #{user}/#{password}.")
        end
      end

      def setup_or_login(user:, password:)
        browser.visit '/'

        if browser.current_path == '/setup'
          setup_and_login(user: user, password: password)
        elsif browser.current_path == '/login'
          login(user: user, password: password)
        end
      end

      private

      attr_reader :browser

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ops_manager_ui_drivers-1.8.3 lib/ops_manager_ui_drivers/version15/setup.rb
ops_manager_ui_drivers-1.9.2 lib/ops_manager_ui_drivers/version15/setup.rb
ops_manager_ui_drivers-1.9.1 lib/ops_manager_ui_drivers/version15/setup.rb
ops_manager_ui_drivers-1.9.0 lib/ops_manager_ui_drivers/version15/setup.rb
ops_manager_ui_drivers-1.8.2 lib/ops_manager_ui_drivers/version15/setup.rb
ops_manager_ui_drivers-1.8.1 lib/ops_manager_ui_drivers/version15/setup.rb