This commit is contained in:
piair
2024-04-26 13:55:20 +02:00
parent 05a1fd8557
commit 22ea727c47
2 changed files with 44 additions and 16 deletions

View File

@ -1,9 +1,9 @@
import os
import json
import os
from random import uniform
from selenium.common import TimeoutException
from selenium.webdriver import ActionChains, Keys
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
@ -14,9 +14,9 @@ from modules.Tools.tools import *
def init_profile(mail, mobile=False):
if not mobile:
chrome_profile_dir = "/app/MsRewards-Reborn/user_data/profile/"+mail
chrome_profile_dir = "/app/MsRewards-Reborn/user_data/profile/" + mail
else:
chrome_profile_dir = "/app/MsRewards-Reborn/user_data/profile/mobile-"+mail
chrome_profile_dir = "/app/MsRewards-Reborn/user_data/profile/mobile-" + mail
os.makedirs(chrome_profile_dir, exist_ok=True)
@ -30,12 +30,12 @@ def init_profile(mail, mobile=False):
"accept_languages": "fr-FR,en-US,en",
"selected_languages": "fr-FR,en-US,en"
}
}, f
}, f
)
else:
with open(preferences_file, "r") as f:
settings = json.load(f)
if "intl" not in settings:
settings["intl"] = {}
@ -69,6 +69,7 @@ def send_keys_wait(element, keys: str) -> None:
element.send_keys(i)
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)
@ -81,6 +82,6 @@ def wait_until_visible(search_by: str, identifier: str, timeout: int = 20, brows
expected_conditions.visibility_of_element_located((search_by, identifier)), "element not found")
return True
except TimeoutException as e:
if raise_error:
error(f"element {identifier} not found after {timeout}s")
f = error if raise_error else debug
f(f"element {identifier} not found after {timeout}s")
return False