Skip to content

Commit

Permalink
Try different chrome versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre0512 committed Dec 8, 2023
1 parent c838f93 commit 202cce4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down
11 changes: 9 additions & 2 deletions lidlplus/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
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
from seleniumwire import webdriver
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

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 202cce4

Please sign in to comment.