Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support text message for Amazon mfa/otp #16

Merged
merged 1 commit into from
May 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/merchants/amazon_gift_card_reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,36 @@ def web_automation(driver, merchant, amount):
except TimeoutException:
pass

try: # OTP text message
WebDriverWait(driver, 5).until(expected_conditions.element_to_be_clickable((By.XPATH, "//*[contains(text(),'phone number ending in')]")))
if driver.find_elements_by_id('auth-mfa-remember-device'):
driver.find_element_by_id('auth-mfa-remember-device').click()

sent_to_text = driver.find_element_by_xpath("//*[contains(text(),'phone number ending in')]").text
LOGGER.info(sent_to_text)
LOGGER.info('Enter OTP here:')
otp = input()

driver.find_element_by_id('auth-mfa-otpcode').send_keys(otp)
driver.find_element_by_id('auth-signin-button').click()
except TimeoutException:
pass

try: # OTP email validation
WebDriverWait(driver, 5).until(expected_conditions.element_to_be_clickable((By.XPATH, "//*[contains(text(),'One Time Password')]")))
otp_flow = True
otp_email = True
except TimeoutException:
otp_flow = False
otp_email = False

try:
driver.find_element_by_xpath("//*[contains(text(),'one-time pass')]").click()
otp_flow = True
otp_email = True
except common.exceptions.NoSuchElementException:
pass

if otp_flow:
driver.find_element_by_id('continue').click()
if otp_email:
if driver.find_elements_by_id('continue'):
driver.find_element_by_id('continue').click()

WebDriverWait(driver, 5).until(expected_conditions.element_to_be_clickable((By.XPATH, "//input")))
sent_to_text = driver.find_element_by_xpath("//*[contains(text(),'@')]").text
Expand Down