Fix 2FA (language setting is not always working)
This commit is contained in:
parent
ba66a96c65
commit
49dc53ed32
31
V6.py
31
V6.py
|
@ -10,6 +10,7 @@ from modules.driver_tools import *
|
||||||
from modules.error import *
|
from modules.error import *
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from selenium.common.exceptions import NoSuchElementException
|
||||||
|
|
||||||
# create a webdriver
|
# create a webdriver
|
||||||
def create_driver(mobile=False):
|
def create_driver(mobile=False):
|
||||||
|
@ -383,20 +384,28 @@ def login_part_1():
|
||||||
driver = config.WebDriver.driver
|
driver = config.WebDriver.driver
|
||||||
driver.get("https://login.live.com")
|
driver.get("https://login.live.com")
|
||||||
wait_until_visible(By.ID, "i0116", browser=driver)
|
wait_until_visible(By.ID, "i0116", browser=driver)
|
||||||
mail_elem = driver.find_element(By.ID, "i0116")
|
send_wait_and_confirm(
|
||||||
send_keys_wait(mail_elem, config.UserCredentials.get_mail())
|
driver.find_element(By.ID, "i0116"),
|
||||||
mail_elem.send_keys(Keys.ENTER)
|
config.UserCredentials.get_mail()
|
||||||
|
)
|
||||||
wait_until_visible(By.ID, "i0118", browser=driver)
|
wait_until_visible(By.ID, "i0118", browser=driver)
|
||||||
pwd_elem = driver.find_element(By.ID, "i0118")
|
send_wait_and_confirm(
|
||||||
send_keys_wait(pwd_elem, config.UserCredentials.get_password())
|
driver.find_element(By.ID, "i0118"),
|
||||||
pwd_elem.send_keys(Keys.ENTER)
|
config.UserCredentials.get_password()
|
||||||
custom_sleep(2)
|
)
|
||||||
# 2FA
|
# 2FA
|
||||||
if "Entrez le code de sécurité" in driver.page_source:
|
|
||||||
try:
|
try:
|
||||||
a2f_elem = driver.find_element(By.ID, "idTxtBx_SAOTCC_OTC")
|
wait_until_visible(By.ID, "idTxtBx_SAOTCC_OTC", browser=driver, timeout=5)
|
||||||
a2f_elem.send_keys(config.UserCredentials.get_tfa().now())
|
|
||||||
a2f_elem.send_keys(Keys.ENTER)
|
a2f_code = config.UserCredentials.get_tfa().now()
|
||||||
|
info(f"Need 2FA, I have code: {a2f_code}")
|
||||||
|
send_wait_and_confirm(
|
||||||
|
driver.find_element(By.ID, "idTxtBx_SAOTCC_OTC"),
|
||||||
|
a2f_code
|
||||||
|
)
|
||||||
|
except NoSuchElementException:
|
||||||
|
custom_sleep(2)
|
||||||
|
pass
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log_error(err)
|
log_error(err)
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,10 @@ def send_keys_wait(element, keys: str) -> None:
|
||||||
element.send_keys(i)
|
element.send_keys(i)
|
||||||
sleep(uniform(0.1, 0.3))
|
sleep(uniform(0.1, 0.3))
|
||||||
|
|
||||||
|
def send_wait_and_confirm(element, keys: str) -> None:
|
||||||
|
send_keys_wait(element, keys)
|
||||||
|
element.send_keys(Keys.ENTER)
|
||||||
|
|
||||||
|
|
||||||
# Wait for the presence of the element identifier or [timeout]s
|
# Wait for the presence of the element identifier or [timeout]s
|
||||||
def wait_until_visible(search_by: str, identifier: str, timeout: int = 20, browser=None) -> bool:
|
def wait_until_visible(search_by: str, identifier: str, timeout: int = 20, browser=None) -> bool:
|
||||||
|
|
Loading…
Reference in New Issue