Selenium Webdriver 导入 ChromeDriverManager 错误

Selenium Webdriver Import ChromeDriverManager Error

我一直在使用 selenium webdriver;但是,我现在正在尝试使用 Java 与页面进行交互(这对我来说是新的)。在尝试这样做时,我发现这个视频似乎正是我要找的:

https://www.youtube.com/watch?v=bBRFVIEiFIE

我不断收到从代码的第二行生成的错误消息:

from selenium import webdriver

from webdriver_manager.chrome import ChromeDriverManager

这是错误信息:

 Traceback (most recent call last):
 File "C:\Users\erich\Desktop\SeleniumDrivers\State Scrape Java.py", line 2, in <module>
 from webdriver_manager.chrome import ChromeDriverManager
 File "C:\Python27\lib\site-packages\webdriver_manager\chrome.py", line 4, in <module>
 from webdriver_manager.driver import ChromeDriver
 File "C:\Python27\lib\site-packages\webdriver_manager\driver.py", line 77
 self.auth_header = {'Authorization': f'token {self._os_token}'}
                                                             ^
 SyntaxError: invalid syntax

我已经确保 pip install webdriver-manager 并在 pypi 上尝试了两个可能的选项。

任何帮助将不胜感激!

尝试:

#selenium4 with python [pip install selenium4)

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

#options to add as arguments
from selenium.webdriver.chrome.options import Options
option = webdriver.ChromeOptions()
option.add_argument("start-maximized")

#chrome to stay open
option.add_experimental_option("detach", True)

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=option)
driver.get('https://www.example.com/')

WebdriverManager