Skip to main content
 首页 » 编程设计

python之无法创建着色器缓存条目 : -2 error with ChromeDriver Chrome and Selenium

2024年12月31日31zengkefu

我是 python 的新手,正在学习 selenium。我想构建一个简单的代码,可以根据输入从 google.com 自动搜索任何内容 我正在按名称访问元素,但出现错误:

Failed to create shader cache entry: -2.

任何人都可以帮助我处理我的代码并纠正我在这里做错了什么??

from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
import time 
from time import sleep 
 
 
driver = webdriver.Chrome() 
driver.get('http://www.google.com') 
 
elem = driver.find_element_by_name('q') 
time.sleep(5) 
elem.clear() 
elem.send_keys("Python") 
elem.send_keys(Keys.RETURN) 

请您参考如下方法:

这个错误信息...

Failed to create shader cache entry: -2 

...是从 shader_disk_cache.cc 中定义的 int ShaderDiskCacheEntry::WriteCallback(int rv) 函数生成的日志条目

主要问题是着色器缓存代码删除除了一个时间戳元组目录之外的所有目录。

根据 Failure to create folder for on-disk shader cache主要问题是着色器缓存代码删除了除一个时间戳元组目录之外的所有目录。


解决方案

作为解决方案,采取了以下步骤:

  • 将所有缓存条目移动到单个缓存目录,并使用时间戳(将来可能是构建 ID 哈希)和 gpu id 作为缓存条目 sha 输入的一部分。
  • 在缓存接近其最大大小时删除旧条目。尽管此解决方案使预编译着色器的收集/分发变得有些困难,但并非无法解决。
  • util/disk_cache:将时间戳散列到缓存键中

Instead of using a directory, hash the timestamps into the cache keys themselves. Since there is no more timestamp directory, there is no more need for deleting the cache of other mesa versions and we rely on eviction to clean up the old cache entries. This solves the problem of using several incarnations of disk_cache at the same time, where one deletes a directory belonging to the other.

您可以在 Failed to create shader cache entry- error while locating an element by its Css selector 中找到相关讨论