From 1eb5726cbf62b59636f742407ee4b398dbdc59c0 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 15 Aug 2022 11:26:04 +0200 Subject: [PATCH] Execute JS should happen after waiting seconds --- changedetectionio/content_fetcher.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index 90988179..b97f1e61 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -319,8 +319,6 @@ class base_html_playwright(Fetcher): with page.expect_navigation(): response = page.goto(url, wait_until='load') - if self.webdriver_js_execute_code is not None: - page.evaluate(self.webdriver_js_execute_code) except playwright._impl._api_types.TimeoutError as e: context.close() @@ -344,6 +342,11 @@ class base_html_playwright(Fetcher): page.set_viewport_size({"width": 1280, "height": 1024}) extra_wait = int(os.getenv("WEBDRIVER_DELAY_BEFORE_CONTENT_READY", 5)) + self.render_extract_delay time.sleep(extra_wait) + + if self.webdriver_js_execute_code is not None: + page.evaluate(self.webdriver_js_execute_code) + time.sleep(2) + self.content = page.content() self.status_code = response.status