on3.7/site-packages/selenium/webdriver/common/driver_finder.py in get_path(service, options) 41 try: ---> 42 path = SeleniumManager().driver_location(options) if path is None else path 43 except Exception as err: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/selenium/webdriver/common/selenium_manager.py in driver_location(self, options) 95 ---> 96 result = self.run(args) 97 executable = result.split("\t")[-1].strip() /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/selenium/webdriver/common/selenium_manager.py in run(args) 120 if completed_proc.returncode: --> 121 raise WebDriverException(f"Unsuccessful command executed: {command}.\n{result}{stderr}") 122 else: WebDriverException: Message: Unsuccessful command executed: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/selenium/webdriver/common/linux/selenium-manager --browser MicrosoftEdge --output json. request or response body error: operation timed out During handling of the above exception, another exception occurred: NoSuchDriverException Traceback (most recent call last)/tmp/ipykernel_94/3666868230.py in <module>
时间: 2024-01-03 19:05:53 浏览: 464
根据您的代码和错误信息,看起来您在使用Selenium WebDriver时遇到了问题。NoSuchDriverException错误表明您的代码无法找到指定的驱动程序。
这个问题可能是由于没有正确安装或配置WebDriver驱动程序引起的。您需要根据您要使用的浏览器类型下载对应的WebDriver驱动程序,并确保将其正确配置到您的代码中。
此外,还需要确保您的网络连接正常,以便能够下载所需的驱动程序。
如果您需要进一步的帮助,请提供更多的代码和详细的错误信息,以便我能够更好地帮助您解决问题。
相关问题
Unable to obtain driver using Selenium Manager: Selenium Manager failed for: E:\excavate\other\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser firefox --output json. error sending request for url (https://github.com/mozilla/geckodriver/releases/latest): connection error: connection reset Traceback (most recent call last): File "E:\Two\pythonProject\main.py", line 3, in <module> driver = webdriver.Firefox() File "E:\excavate\other\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 195, in __init__ self.service.path = DriverFinder.get_path(self.service, options) File "E:\excavate\other\lib\site-packages\selenium\webdriver\common\driver_finder.py", line 43, in get_path raise err File "E:\excavate\other\lib\site-packages\selenium\webdriver\common\driver_finder.py", line 40, in get_path path = shutil.which(service.path) or SeleniumManager().driver_location(options) File "E:\excavate\other\lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 91, in driver_location result = self.run(args) File "E:\excavate\other\lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 112, in run raise SeleniumManagerException(f"Selenium Manager failed for: {command}.\n{result}{stderr}") selenium.common.exceptions.SeleniumManagerException: Message: Selenium Manager failed for: E:\excavate\other\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser firefox --output json. error sending request for url (https://github.com/mozilla/geckodriver/releases/latest): connection error: connection reset Process finished with exit code 1
这个错误通常发生在Selenium无法从GitHub下载驱动程序时。这可能是由于网络连接问题或GitHub服务器问题引起的。
你可以尝试手动下载geckodriver并将其添加到系统PATH环境变量中。请根据你的操作系统和Firefox浏览器版本下载相应的geckodriver版本。下载地址是:https://github.com/mozilla/geckodriver/releases
如果手动下载并配置geckodriver仍然无法解决问题,你可以尝试使用Firefox的ESR(Extended Support Release)版本,这个版本不需要每个版本都使用新的geckodriver驱动程序。你可以在这里下载Firefox ESR:https://www.mozilla.org/en-US/firefox/organizations/all/
如果问题仍然存在,请提供更多的代码和错误信息,以便更好地诊断问题。
Traceback (most recent call last): File "C:\Users\Lenovo\PycharmProjects\SeleniumDemo\first-demo.py", line 2, in <module> driver=webdriver.Chrome("./chromedriver.exe") File "C:\Users\Lenovo\PycharmProjects\SeleniumDemo\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 47, in __init__ self.service.path = DriverFinder.get_path(self.service, self.options) File "C:\Users\Lenovo\PycharmProjects\SeleniumDemo\venv\lib\site-packages\selenium\webdriver\common\driver_finder.py", line 44, in get_path raise NoSuchDriverException(f"Unable to obtain {service.path} using Selenium Manager; {err}") selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain chromedriver using Selenium Manager; 'str' object has no attribute 'capabilities'; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
这个错误是由于找不到 ChromeDriver 驱动程序所致。你需要确保你的代码中指定的 ChromeDriver 路径是正确的,并且已经下载并保存在指定的路径中。另外,你需要检查你的 Chrome 浏览器版本与你下载的 ChromeDriver 版本是否匹配。如果 Chrome 浏览器版本与 ChromeDriver 版本不匹配,你需要下载与你的 Chrome 浏览器版本相对应的 ChromeDriver。
阅读全文