Class: AwsAccountUtils::Password

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#screenshot

Constructor Details

#initialize(logger, browser) ⇒ Password

Returns a new instance of Password.



8
9
10
11
# File 'lib/aws_account_utils/password.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/password.rb', line 6

def browser
  @browser
end

#loggerObject (readonly)

Returns the value of attribute logger.



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

def logger
  @logger
end

Instance Method Details

#change(account_email, account_password, new_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
# File 'lib/aws_account_utils/password.rb', line 13

def change(, , new_password)
  logger.debug 'Changing root password.'
  Login.new(logger, browser).execute url,
                                     ,
                                     
  browser.h1(:text => /Change Name, E-mail Address, or Password/).wait_until_present
  screenshot(browser, "1")
  browser.button(:id => 'cnep_1A_change_password_button-input').when_present.click
  screenshot(browser, "2")
  browser.text_field(:id =>"ap_password").when_present.set 
  browser.text_field(:id =>"ap_password_new").when_present.set new_password
  browser.text_field(:id =>"ap_password_new_check").when_present.set new_password
  screenshot(browser, "3")
  browser.button(:id => "cnep_1D_submit_button-input").when_present.click
  raise StandardError if browser.div(:id => /message_(error|warning)/).exist?
  browser.h6(:text => /Success/).exist?
rescue StandardError => e
  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 Password Change Error: \"#{error_header}: #{error_body}\""

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