Class: AwsAccountUtils::ChallengeQuestions

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#screenshot

Constructor Details

#initialize(logger, browser) ⇒ ChallengeQuestions

Returns a new instance of ChallengeQuestions.



9
10
11
12
# File 'lib/aws_account_utils/challenge_questions.rb', line 9

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

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



7
8
9
# File 'lib/aws_account_utils/challenge_questions.rb', line 7

def browser
  @browser
end

#loggerObject (readonly)

Returns the value of attribute logger.



7
8
9
# File 'lib/aws_account_utils/challenge_questions.rb', line 7

def logger
  @logger
end

Instance Method Details

#create(account_email, account_password, challenge_words = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/aws_account_utils/challenge_questions.rb', line 14

def create(, , challenge_words = {})
  logger.debug "Setting security challenge answers."
  Login.new(logger, browser).execute url,
                                     ,
                                     

  browser.a(:xpath => '//a[@ng-click="toggleEditingSecurityQuestionsInfoState()"]').when_present.click

  challenge_words.each do |num, word|
    browser.input(:xpath => "//input[@ng-model=\"selectedSecurityQuestions.question#{num}.answer\"]").to_subtype.when_present.set word
  end

  screenshot(browser, "1")
  browser.button(:xpath => '//button[@ng-click="updateSecurityQuestions()"]').when_present.click
  browser.a(:xpath => '//a[@ng-click="toggleEditingSecurityQuestionsInfoState()"]').wait_until_present
  challenge_words
rescue Watir::Wait::TimeoutError, Net::ReadTimeout => e
  screenshot(browser, "error")
  raise StandardError, "#{self.class.name} - #{e}"
end