wip
This commit is contained in:
@@ -2,11 +2,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import undetected_chromedriver as uc
|
||||
from selenium.common.exceptions import TimeoutException
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
||||
from config import config
|
||||
from crawler.driver import human_delay, make_driver
|
||||
from crawler.driver import human_delay
|
||||
|
||||
|
||||
class FreshSessionScenario:
|
||||
@@ -19,8 +17,9 @@ class FreshSessionScenario:
|
||||
explicitly delete all cookies after loading to be safe.
|
||||
"""
|
||||
|
||||
def __init__(self, driver: uc.Chrome, timeout: int = 30) -> None:
|
||||
def __init__(self, driver: uc.Chrome, url: str, timeout: int = 30) -> None:
|
||||
self.driver = driver
|
||||
self.url = url
|
||||
self.wait = WebDriverWait(driver, timeout)
|
||||
|
||||
def run(self) -> dict[str, object]:
|
||||
@@ -32,7 +31,7 @@ class FreshSessionScenario:
|
||||
"try { window.localStorage.clear(); window.sessionStorage.clear(); } catch(e) {}"
|
||||
)
|
||||
|
||||
self.driver.get(config.target_url)
|
||||
self.driver.get(self.url)
|
||||
human_delay(2.0, 4.0)
|
||||
|
||||
# Wait for the page to reach a ready state
|
||||
|
||||
@@ -10,7 +10,6 @@ from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
||||
from config import config
|
||||
from crawler.driver import human_delay
|
||||
|
||||
|
||||
@@ -32,11 +31,13 @@ class OTPLoginScenario:
|
||||
driver: uc.Chrome,
|
||||
phone: str,
|
||||
otp_resolver: Callable[[str], str],
|
||||
url: str,
|
||||
timeout: int = 30,
|
||||
) -> None:
|
||||
self.driver = driver
|
||||
self.phone = phone
|
||||
self.otp_resolver = otp_resolver
|
||||
self.url = url
|
||||
self.wait = WebDriverWait(driver, timeout)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
@@ -50,7 +51,7 @@ class OTPLoginScenario:
|
||||
|
||||
def run(self) -> dict[str, object]:
|
||||
"""Execute the OTP login. Returns a result dict."""
|
||||
self.driver.get(config.target_url)
|
||||
self.driver.get(self.url)
|
||||
human_delay(1.5, 3.0)
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user