Class: AwsAccountUtils::AccountRegistration

Inherits:
Base
  • Object
show all
Defined in:
lib/aws_account_utils/account_registration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#screenshot

Constructor Details

#initialize(logger, browser) ⇒ AccountRegistration

Returns a new instance of AccountRegistration.



8
9
10
11
# File 'lib/aws_account_utils/account_registration.rb', line 8

def initialize(logger, browser)
  @logger = logger
  @browser = browser
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



6
7
8
# File 'lib/aws_account_utils/account_registration.rb', line 6

def browser
  @browser
end

#loggerObject (readonly)

Returns the value of attribute logger.



6
7
8
# File 'lib/aws_account_utils/account_registration.rb', line 6

def logger
  @logger
end

Instance Method Details

#signup(account_name, account_email, account_password) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/aws_account_utils/account_registration.rb', line 13

def (, , )
  logger.debug "Signing up for a new account."
   = { 'ap_customer_name'  => ,
                    'ap_email'          => ,
                    'ap_email_check'    => ,
                    'ap_password'       => ,
                    'ap_password_check' =>  }

  browser.goto 
  browser.text_field(:id => 'ap_customer_name').wait_until_present
  screenshot(browser, "1")
  .each do |k,v|
    browser.text_field(:id => k).when_present.set v
  end
  screenshot(browser, "2")
  browser.button(:id => 'continue-input').when_present.click
  raise StandardError if browser.div(:id => /message_(error|warning)/).exist?
  true
rescue StandardError
  screenshot(browser, "error")
  error_header = browser.div(:id => /message_(error|warning)/).h6.text
  error_body = browser.div(:id => /message_(error|warning)/).p.text
  raise StandardError, "AWS signup error: \"#{error_header}: #{error_body}\""

rescue Watir::Wait::TimeoutError, Net::ReadTimeout => e
  screenshot(browser, "error")
  raise StandardError, "#{self.class.name} - #{e}"
end