Sha256: 2d85a62795c3feb9a980ccfab32046e086b7d2ddb0f7d0f652f33d637d089215

Contents?: true

Size: 852 Bytes

Versions: 5

Compression:

Stored size: 852 Bytes

Contents

module Mechanize
  class Login < Agent
    attr_accessor :agent
    def initialize(params={})
      retry_ct = 0
      params[:user] ||= ''
      params[:password] ||= ''
      params[:login_url] ||= ''
      flow = NavigationPaths::Login.new(params[:user], params[:password])
        
      begin
        @agent = @@agent
        @page = @@agent.get "#{$cfg[:base_url]}/#{params[:login_url]}"
        @page = @@agent.go($cfg, page, flow.navigation_path) 
        f = @page.forms.first
        @page = f.submit
      rescue TypeError, Net::HTTPBadGateway, Errno::ECONNRESET => e
        retry_ct += 1

        # if we can't create initiator within 3 tries raise error
        unless retry_ct > Constants::Rescue::RETRY_NUM
          puts "Retrying: #{e.inspect}"
          retry
        else
          raise e
        end
      end
    end  
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
qa_robusta-0.1.9 mechanize_interface/lib/login.rb
qa_robusta-0.1.8 mechanize_interface/lib/login.rb
qa_robusta-0.1.5 mechanize_interface/lib/login.rb
qa_robusta-0.1.4 mechanize_interface/lib/login.rb
qa_robusta-0.1.3 mechanize_interface/lib/login.rb