webdriver_manager.chrome import ChromeDriverManager的'未解析的引用错误' '

az31mfrm  于 2023-06-27  发布在  Go
关注(0)|答案(2)|浏览(404)

我正在创建一个应用程序,应与网站互动,重要的代码如下所列。因此,当从'webdriver_manager.chrome'导入'ChromeDriverManager'时,我会收到错误“unresolved reference 'webdriver_manager'”和“unresolved reference'ChromeDriverManager'”。问题是,我想自动更新chromedriver,这是我想出的解决方案,但在pycharm中运行它时不会工作,但当我从控制台运行它时,它会工作......有人对此有解决方案吗?因为我更喜欢在pycharm中测试我的代码,而不是每次都从控制台启动它。

from selenium import webdriver 
from webdriver_manager.chrome import ChromeDriverManager # important for chromedriver-autoinstall
import time
p= ChromeDriverManager()
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging", "enable-automation"])
# disables 'Browser is managed by test software' and surpresses error with USB device
driver = webdriver.Chrome(executable_path=p.install(), options=chrome_options)
# see above + install right version of chromedriver
t = 2  # time to wait for input of number
i = 1  # current round
duration = 1
slsn1g29

slsn1g291#

有同样的问题,因为包没有显示在解释器中。我最终只是通过设置手动安装webdriver-manager。
Package installation interface

iyfjxgzm

iyfjxgzm2#

selenium4.10.0中,驱动程序管理器现已包含在测试版中,因此您可能根本不需要使用ChromeDriverManager:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging", "enable-automation"])

driver = webdriver.Chrome(options=chrome_options)
# ...
driver.quit()

相关问题