Class: AwsAccountUtils::Password
- Defined in:
- lib/aws_account_utils/password.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #change(account_email, account_password, new_password) ⇒ Object
-
#initialize(logger, browser) ⇒ Password
constructor
A new instance of Password.
Methods inherited from Base
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
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
6 7 8 |
# File 'lib/aws_account_utils/password.rb', line 6 def browser @browser end |
#logger ⇒ Object (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(account_email, account_password, new_password) logger.debug 'Changing root password.' Login.new(logger, browser).execute url, account_email, account_password browser.h1(:text => /Change Name, E-mail Address, or Password/).wait_until_present screenshot(browser, "1") browser.(:id => 'cnep_1A_change_password_button-input').when_present.click screenshot(browser, "2") browser.text_field(:id =>"ap_password").when_present.set account_password 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.(: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 |