|
20 | 20 | from getuseragent import UserAgent
|
21 | 21 | from oic.oic import Client
|
22 | 22 | from oic.utils.authn.client import CLIENT_AUTHN_METHOD
|
23 |
| - from selenium.webdriver.chrome.service import Service as ChromeService |
| 23 | + from selenium.webdriver.chrome.service import Service |
24 | 24 | from selenium.webdriver.common.by import By
|
25 | 25 | from selenium.webdriver.support import expected_conditions
|
26 | 26 | from selenium.webdriver.support.ui import WebDriverWait
|
27 | 27 | from seleniumwire import webdriver
|
28 | 28 | from seleniumwire.utils import decode
|
29 | 29 | from webdriver_manager.chrome import ChromeDriverManager
|
30 | 30 | from webdriver_manager.firefox import GeckoDriverManager
|
| 31 | + from webdriver_manager.core.os_manager import ChromeType |
31 | 32 | except ImportError:
|
32 | 33 | pass
|
33 | 34 |
|
@@ -87,7 +88,13 @@ def _init_chrome(self, headless=True):
|
87 | 88 | if headless:
|
88 | 89 | options.add_argument("headless")
|
89 | 90 | options.add_experimental_option("mobileEmulation", {"userAgent": user_agent})
|
90 |
| - return webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=options) |
| 91 | + for chrome_type in [ChromeType.GOOGLE, ChromeType.MSEDGE, ChromeType.CHROMIUM]: |
| 92 | + try: |
| 93 | + service = Service(ChromeDriverManager(chrome_type=chrome_type).install()) |
| 94 | + return webdriver.Chrome(service=service, options=options) |
| 95 | + except AttributeError: |
| 96 | + continue |
| 97 | + raise WebBrowserException("Unable to find a suitable Chrome driver") |
91 | 98 |
|
92 | 99 | def _init_firefox(self, headless=True):
|
93 | 100 | user_agent = UserAgent(self._OS.lower()).Random()
|
|
0 commit comments