python - 如何使用 selenium 和 Python 从浏览器控制台获取错误和警告?
问题描述
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
dc = DesiredCapabilities.CHROME
dc['goog:loggingPrefs'] = { 'browser':'ALL' }
driver = webdriver.Chrome(desired_capabilities=dc)
driver.implicitly_wait(30)
for entry in driver.get_log('browser'):
print(entry)
driver.quit()
我运行上面的代码,但在 pycharm 中出现以下 2 个错误
in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
在处理上述异常的过程中,又出现了一个异常:
in start raise WebDriverException(selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.
解决方案
推荐阅读
- r - 从 R Shiny 中的反应输入中保存绘图时出现问题
- python - 登录异步函数时如何使用 request_id?
- javascript - 如何在使用 bitbucket 时修复节点 js 错误
- java - 从满足特定模式的字符串中获取表达式
- python - 用于数据帧转换的 pandas wide_long vs (stack and melt)
- delphi - Delphi 7启动时打开一个cmd
- android - 未解决的对 DaggerComponent 的引用
- typescript - 如何正确标准化对象?
- browser - 有没有办法在 Oculus 浏览器上访问本地文件系统?
- excel - 如何加快删除大型 Excel 文件中的工作表?