From 0aef5483d917ca502877bffc8b34bc68cc1355e6 Mon Sep 17 00:00:00 2001 From: Marcelo Alencar Date: Thu, 26 Oct 2023 05:09:03 -0300 Subject: [PATCH] Upgrade selenium to 4.14.0 (latest) (#1783) --- .github/workflows/test-only.yml | 4 ++-- changedetectionio/content_fetcher.py | 13 ++++++++----- requirements.txt | 3 +-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-only.yml b/.github/workflows/test-only.yml index 09a5d365..0b0bb5a7 100644 --- a/.github/workflows/test-only.yml +++ b/.github/workflows/test-only.yml @@ -29,8 +29,8 @@ jobs: docker network create changedet-network # Selenium+browserless - docker run --network changedet-network -d --hostname selenium -p 4444:4444 --rm --shm-size="2g" selenium/standalone-chrome-debug:3.141.59 - docker run --network changedet-network -d --hostname browserless -e "FUNCTION_BUILT_INS=[\"fs\",\"crypto\"]" -e "DEFAULT_LAUNCH_ARGS=[\"--window-size=1920,1080\"]" --rm -p 3000:3000 --shm-size="2g" browserless/chrome:1.53-chrome-stable + docker run --network changedet-network -d --hostname selenium -p 4444:4444 --rm --shm-size="2g" selenium/standalone-chrome:4.14.1 + docker run --network changedet-network -d --hostname browserless -e "FUNCTION_BUILT_INS=[\"fs\",\"crypto\"]" -e "DEFAULT_LAUNCH_ARGS=[\"--window-size=1920,1080\"]" --rm -p 3000:3000 --shm-size="2g" browserless/chrome:1.60-chrome-stable - name: Build changedetection.io container for testing run: | diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index 97b4e0b1..9b4e9deb 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -614,14 +614,17 @@ class base_html_webdriver(Fetcher): is_binary=False): from selenium import webdriver - from selenium.webdriver.common.desired_capabilities import DesiredCapabilities + from selenium.webdriver.chrome.options import Options as ChromeOptions from selenium.common.exceptions import WebDriverException # request_body, request_method unused for now, until some magic in the future happens. + options = ChromeOptions() + if self.proxy: + options.proxy = self.proxy + self.driver = webdriver.Remote( command_executor=self.command_executor, - desired_capabilities=DesiredCapabilities.CHROME, - proxy=self.proxy) + options=options) try: self.driver.get(url) @@ -653,11 +656,11 @@ class base_html_webdriver(Fetcher): # Does the connection to the webdriver work? run a test connection. def is_ready(self): from selenium import webdriver - from selenium.webdriver.common.desired_capabilities import DesiredCapabilities + from selenium.webdriver.chrome.options import Options as ChromeOptions self.driver = webdriver.Remote( command_executor=self.command_executor, - desired_capabilities=DesiredCapabilities.CHROME) + options=ChromeOptions()) # driver.quit() seems to cause better exceptions self.quit() diff --git a/requirements.txt b/requirements.txt index 81438733..8d050066 100644 --- a/requirements.txt +++ b/requirements.txt @@ -49,8 +49,7 @@ beautifulsoup4 # XPath filtering, lxml is required by bs4 anyway, but put it here to be safe. lxml -# 3.141 was missing socksVersion, 3.150 was not in pypi, so we try 4.1.0 -selenium~=4.1.0 +selenium~=4.14.0 # https://stackoverflow.com/questions/71652965/importerror-cannot-import-name-safe-str-cmp-from-werkzeug-security/71653849#71653849 # ImportError: cannot import name 'safe_str_cmp' from 'werkzeug.security'