Simplify page load strat, move some messages around

This commit is contained in:
DevilXD committed 2022-11-11 18:19:08 +01:00
1 parent d3d1624a24
commit 71d4bf5092
1 file changed
+5 -7
+5 -7
View File
@@ -27,7 +27,6 @@ try:
from seleniumwire.request import Request from seleniumwire.request import Request
from selenium.common.exceptions import WebDriverException from selenium.common.exceptions import WebDriverException
from seleniumwire.undetected_chromedriver import Chrome, ChromeOptions from seleniumwire.undetected_chromedriver import Chrome, ChromeOptions
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
except ImportError as exc: except ImportError as exc:
raise ImportError( raise ImportError(
"You need to install Visual C++ Redist (x86 and x64): " "You need to install Visual C++ Redist (x86 and x64): "
@@ -494,9 +493,7 @@ class LoginForm:
options.add_argument("--no-sandbox") options.add_argument("--no-sandbox")
options.add_argument("--test-type") options.add_argument("--test-type")
options.add_argument("--disable-gpu") options.add_argument("--disable-gpu")
desired_capabilities = DesiredCapabilities.CHROME.copy() options.set_capability("pageLoadStrategy", "eager")
# speed up page loading detection
desired_capabilities["pageLoadStrategy"] = "eager"
try: try:
driver_coro = loop.run_in_executor( driver_coro = loop.run_in_executor(
None, None,
@@ -505,7 +502,6 @@ class LoginForm:
suppress_welcome=True, suppress_welcome=True,
version_main=version_main, version_main=version_main,
service_creationflags=CREATE_NO_WINDOW, service_creationflags=CREATE_NO_WINDOW,
desired_capabilities=desired_capabilities,
# user_data_dir=str(CACHE_PATH.joinpath("ChromeProfile")), # user_data_dir=str(CACHE_PATH.joinpath("ChromeProfile")),
) )
) )
@@ -539,6 +535,9 @@ class LoginForm:
await self._manager.coro_unless_closed(page_coro) await self._manager.coro_unless_closed(page_coro)
# enable the login button once the page finishes opening # enable the login button once the page finishes opening
self._button.config(state="normal") self._button.config(state="normal")
self._manager.print(
"Complete the login procedure manually by pressing the Login button again."
)
# auto login # auto login
# driver.find_element("id", "login-username").send_keys(username) # driver.find_element("id", "login-username").send_keys(username)
@@ -584,8 +583,7 @@ class LoginForm:
except WebDriverException: except WebDriverException:
driver = None driver = None
raise LoginException( raise LoginException(
"Chrome window was closed before the login procedure could complete.\n" "Chrome window was closed before the login procedure could complete."
"You can manually complete the procedure by pressing the Login button again."
) )
finally: finally:
self._button.config(state="disabled") self._button.config(state="disabled")