From 202cce4d7b301131042348522d71f2ee2330befe Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Fri, 8 Dec 2023 23:02:11 +0100 Subject: [PATCH] Try different chrome versions --- README.md | 1 + lidlplus/api.py | 11 +++++++++-- setup.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b27741f..18d8f8d 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ After we have received the token once, we can use it for further requestes and w - Chromium - Google Chrome - Mozilla Firefox + - Microsoft Edge * Install additional python packages ```bash pip install "lidl-plus[auth]" diff --git a/lidlplus/api.py b/lidlplus/api.py index ce4820e..aa7c093 100644 --- a/lidlplus/api.py +++ b/lidlplus/api.py @@ -20,7 +20,7 @@ from getuseragent import UserAgent from oic.oic import Client from oic.utils.authn.client import CLIENT_AUTHN_METHOD - from selenium.webdriver.chrome.service import Service as ChromeService + from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions from selenium.webdriver.support.ui import WebDriverWait @@ -28,6 +28,7 @@ from seleniumwire.utils import decode from webdriver_manager.chrome import ChromeDriverManager from webdriver_manager.firefox import GeckoDriverManager + from webdriver_manager.core.os_manager import ChromeType except ImportError: pass @@ -87,7 +88,13 @@ def _init_chrome(self, headless=True): if headless: options.add_argument("headless") options.add_experimental_option("mobileEmulation", {"userAgent": user_agent}) - return webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options) + for chrome_type in [ChromeType.GOOGLE, ChromeType.MSEDGE, ChromeType.CHROMIUM]: + try: + service = Service(ChromeDriverManager(chrome_type=chrome_type).install()) + return webdriver.Chrome(service=service, options=options) + except AttributeError: + continue + raise WebBrowserException("Unable to find a suitable Chrome driver") def _init_firefox(self, headless=True): user_agent = UserAgent(self._OS.lower()).Random() diff --git a/setup.py b/setup.py index bc3e80b..69c8837 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name="lidl-plus", - version="0.3.2", + version="0.3.4", author="Andre Basche", description="Fetch receipts and more from Lidl Plus", long_description=long_description,