Selenium chromdriver一直给我错误



我已经能够利用硒铬一段时间。我尝试使用

捕获错误
try:
#check if it already exist before doing anything
webdriver.driver
except:
chromeBrowser=ChromeDriverManager().install() 
....... some other code here

上面的代码工作得很好,它捕获错误并加载浏览器没有任何问题。突然,它开始给我这个错误,没有超出这个范围。它甚至根本没有进入互联网。

ERROR: The system was unable to find the specified registry key or value.
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:Userspure_springAppDataLocalProgramsPythonPython38libthreading.py", line 932, in _bootstrap_inner
self.run()
File "C:Userspure_springAppDataLocalProgramsPythonPython38libthreading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:python_srcschoolschoolhostviews.py", line 2333, in loopTest
chromeBrowser = ChromeDriverManager().install()
File "C:python_srcvenvlibsite-packageswebdriver_managerchrome.py", line 23,
in __init__
self.driver = ChromeDriver(name=name,
File "C:python_srcvenvlibsite-packageswebdriver_managerdriver.py", line 54,
in __init__
self.browser_version = chrome_version(chrome_type)
File "C:python_srcvenvlibsite-packageswebdriver_managerutils.py", line 155,
in chrome_version
raise ValueError(f'Could not get version for Chrome with this command: {cmd}')
ValueError: Could not get version for Chrome with this command: reg query "HKEY_CURRENT_USERSoftwareGoogleChromeBLBe
acon" /v version
--- Logging error ---
Traceback (most recent call last):
File "C:Userspure_springAppDataLocalProgramsPythonPython38liblogging__init__.py", line 1081, in emit
msg = self.format(record)
File "C:Userspure_springAppDataLocalProgramsPythonPython38liblogging__init__.py", line 925, in format
return fmt.format(record)
File "C:Userspure_springAppDataLocalProgramsPythonPython38liblogging__init__.py", line 672, in format
record.exc_text = self.formatException(record.exc_info)
File "C:Userspure_springAppDataLocalProgramsPythonPython38liblogging__init__.py", line 622, in formatException
traceback.print_exception(ei[0], ei[1], tb, None, sio)
File "C:Userspure_springAppDataLocalProgramsPythonPython38libtraceback.py", line 103, in print_exception
for line in TracebackException(
File "C:python_srcvenvlibsite-packagestrio_core_multierror.py", line 393, i
n traceback_exception_init
traceback_exception_original_init(
File "C:Userspure_springAppDataLocalProgramsPythonPython38libtraceback.py", line 508, in __init__
self.stack = StackSummary.extract(
File "C:Userspure_springAppDataLocalProgramsPythonPython38libtraceback.py", line 366, in extract
f.line
File "C:Userspure_springAppDataLocalProgramsPythonPython38libtraceback.py", line 288, in line
self._line = linecache.getline(self.filename, self.lineno).strip()
File "C:Userspure_springAppDataLocalProgramsPythonPython38liblinecache.py", line 16, in getline
lines = getlines(filename, module_globals)
File "C:Userspure_springAppDataLocalProgramsPythonPython38liblinecache.py", line 47, in getlines
return updatecache(filename, module_globals)
File "C:Userspure_springAppDataLocalProgramsPythonPython38liblinecache.py", line 137, in updatecache
lines = fp.readlines()
File "C:Userspure_springAppDataLocalProgramsPythonPython38libcodecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 1288: invalid start byte
Call stack:
File "C:Userspure_springAppDataLocalProgramsPythonPython38libthreading.py", line 890, in _bootstrap
self._bootstrap_inner()
File "C:Userspure_springAppDataLocalProgramsPythonPython38libthreading.py", line 932, in _bootstrap_inner
self.run()
File "C:Userspure_springAppDataLocalProgramsPythonPython38libthreading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:python_srcvenvlibsite-packagesdjangoutilsautoreload.py", line 53, i
n wrapper
fn(*args, **kwargs)
File "C:python_srcvenvlibsite-packageschannelsmanagementcommandsrunserver.
py", line 106, in inner_run
self.server_cls(
File "C:python_srcvenvlibsite-packagesdaphneserver.py", line 143, in run
reactor.run(installSignalHandlers=self.signal_handlers)
File "C:python_srcvenvlibsite-packagestwistedinternetasyncioreactor.py", li
ne 255, in run
self._asyncioEventloop.run_forever()
File "C:Userspure_springAppDataLocalProgramsPythonPython38libasynciobase_events.py", line 570, in run_forever
self._run_once()
File "C:Userspure_springAppDataLocalProgramsPythonPython38libasynciobase_events.py", line 1859, in _run_once
handle._run()
File "C:Userspure_springAppDataLocalProgramsPythonPython38libasyncioevents.py", line 81, in _run
self._context.run(self._callback, *self._args)
File "C:python_srcvenvlibsite-packagestwistedinternetasyncioreactor.py", li
ne 271, in _onTimer
self.runUntilCurrent()
File "C:python_srcvenvlibsite-packagestwistedinternetbase.py", line 991, in
runUntilCurrent
call.func(*call.args, **call.kw)
File "C:python_srcvenvlibsite-packagesdaphneserver.py", line 290, in applica
tion_checker
logger.error(
Message: 'Exception inside application: %s'
Arguments: (NameError("name 'webdriver' is not defined"),)

请我现在该怎么办,我不知道该怎么办。我甚至完全删除了try异常语句,但这并没有帮助。

这一切都是在我升级selenium后不久开始的。之后,我试图逆转升级,但可以得到初始版本,但我仍然使用另一个版本,但它仍然给我相同的错误。

通常在selenium升级之前,它会为我下载驱动程序并运行浏览器。但是现在连我的网络都连接不上了。

在你的错误堆栈中有这个错误:

Could not get version for Chrome with this command: reg query "HKEY_CURRENT_USERSoftwareGoogleChromeBLBe
acon" /v version

在这个错误后面会出现一些重复的问题。你试过这些帖子里的建议吗?它们能解决你的问题吗?

似乎python无法找到chrome,这就是为什么你得到错误。

相关内容

  • 没有找到相关文章

最新更新