Bypass suspicious loggin attempt verification.
(
browser, logger, logfolder, bypass_security_challenge_using
)
| 30 | |
| 31 | |
| 32 | def bypass_suspicious_login( |
| 33 | browser, logger, logfolder, bypass_security_challenge_using |
| 34 | ): |
| 35 | """Bypass suspicious loggin attempt verification.""" |
| 36 | |
| 37 | # close sign up Instagram modal if available |
| 38 | dismiss_get_app_offer(browser, logger) |
| 39 | dismiss_notification_offer(browser, logger) |
| 40 | dismiss_this_was_me(browser) |
| 41 | |
| 42 | option = None |
| 43 | if bypass_security_challenge_using == "sms": |
| 44 | try: |
| 45 | option = browser.find_element( |
| 46 | By.XPATH, |
| 47 | read_xpath(bypass_suspicious_login.__name__, "bypass_with_sms_option"), |
| 48 | ) |
| 49 | except NoSuchElementException: |
| 50 | logger.warning( |
| 51 | "Unable to choose ({}) option to bypass the challenge".format( |
| 52 | bypass_security_challenge_using.upper() |
| 53 | ) |
| 54 | ) |
| 55 | |
| 56 | if bypass_security_challenge_using == "email": |
| 57 | try: |
| 58 | option = browser.find_element( |
| 59 | By.XPATH, |
| 60 | read_xpath( |
| 61 | bypass_suspicious_login.__name__, "bypass_with_email_option" |
| 62 | ), |
| 63 | ) |
| 64 | except NoSuchElementException: |
| 65 | logger.warning( |
| 66 | "Unable to choose ({}) option to bypass the challenge".format( |
| 67 | bypass_security_challenge_using.upper() |
| 68 | ) |
| 69 | ) |
| 70 | |
| 71 | # click on your option |
| 72 | (ActionChains(browser).move_to_element(option).click().perform()) |
| 73 | # next button click will miss the DOM reference for this element, so -> |
| 74 | option_text = option.text |
| 75 | |
| 76 | # click on security code |
| 77 | send_security_code_button = browser.find_element( |
| 78 | By.XPATH, |
| 79 | read_xpath(bypass_suspicious_login.__name__, "send_security_code_button"), |
| 80 | ) |
| 81 | (ActionChains(browser).move_to_element(send_security_code_button).click().perform()) |
| 82 | |
| 83 | # update server calls |
| 84 | update_activity(browser, state=None) |
| 85 | |
| 86 | logger.info("Instagram detected an unusual login attempt") |
| 87 | logger.info('Check Instagram App for "Suspicious Login attempt" prompt') |
| 88 | logger.info("A security code was sent to your {}".format(option_text)) |
| 89 |
no test coverage detected