diff --git a/newsfragments/1496.change.rst b/newsfragments/1496.change.rst new file mode 100644 index 00000000..12ac7345 --- /dev/null +++ b/newsfragments/1496.change.rst @@ -0,0 +1,3 @@ +Set Chrome's page load strategy to ``eager``, so that navigation does not +wait for images and third-party scripts which no operation in this +package needs. diff --git a/src/vws_web_tools/__init__.py b/src/vws_web_tools/__init__.py index 6c9e88c7..7c319b20 100644 --- a/src/vws_web_tools/__init__.py +++ b/src/vws_web_tools/__init__.py @@ -71,6 +71,13 @@ def create_chrome_driver() -> WebDriver: """Create a headless Chrome WebDriver.""" options = ChromeOptions() + # Return from ``driver.get`` once the DOM is ready, without waiting + # for sub-resources. Every element this package looks for is behind + # an explicit wait, and ``wait_for_logged_in`` asks for + # ``document.readyState`` where a full load is what matters, so + # waiting for images and analytics scripts to load only adds time + # and turns slow third-party requests into timeouts. + options.page_load_strategy = "eager" # noqa: V101 options.add_argument(argument="--headless=new") options.add_argument(argument="--no-sandbox") options.add_argument(argument="--disable-dev-shm-usage")