python - 无法创建着色器缓存条目 - 在通过其 Css 选择器定位元素时出错

标签 python css selenium selenium-webdriver selenium-chromedriver

我正在使用 Selenium 在 Python 中编写一个简单的脚本,以通过其 Css 选择器检测元素。我正在访问 Google 页面,并通过其 CSS 选择器将输入作为输入 [name=q]

Chrome 页面按计划打开,但问题是它在没有实际找到输入的情况下关闭,并在终端中抛出以下错误:ERROR:shader_disk_cache.cc(237)] Failed to create shader cache entry: -2

我尝试在 Google Chrome 关闭时运行该脚本,甚至关闭了任务管理器中的所有 Chrome 进程,但它仍然提示着色器缓存条目。

我应该在这里做什么?

我的代码是:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path=r'C:\Python27\chromedriver.exe')
driver.get("http://www.google.com")
fLocator = "input[name=q]"
try:
    searchField = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, fLocator)))
finally:
    driver.quit() 

Error that I'm getting in the PyCharm's terminal

最佳答案

您的代码近乎完美。您需要进行如下小改动:

编辑 CSS_SELECTOR 来自:

fLocator = "input[name=q]"

收件人:

fLocator = "input[name='q']"

更新:

查看错误、重现错误以及对 these 的一些研究几个linksdiscussions我觉得 shader_disk_cache.ccshader_disk_cache.h 以某种方式损坏了。我认为彻底卸载 Google Chrome(使用 Revo Uninstaller)并完成磁盘清理(使用 CCleaner)并最终安装最新的 Google Chrome 可能会让我们摆脱错误。

关于python - 无法创建着色器缓存条目 - 在通过其 Css 选择器定位元素时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46393818/

相关文章:

python - 如何获取URL缩短页面的结果值?

java - 单击具有数组或列表中的值的按钮

python - 如何在交互模式下使用Elmo词嵌入与原始预训练模型(5.5B)

html - WordPress 搜索表单不会在缩放时调整大小

python - 比较多个数据帧添加新列填充二进制值以进行匹配

html - 如何在实体化的文本内容后面设置背景幻灯片?

html - 悬停菜单消失得太快

linux - 本地工作的 selenium 浏览器下载文件自动化代码在 aws linux 服务器中不起作用?

python - 如何在python中显示没有秒的区域设置敏感时间格式

下载 zip 文件时的 Python Flask 已损坏