Failed to create shader cache entry- error while locating an element by its Css selector

匿名 (未验证) 提交于 2019-12-03 01:10:02

问题:

I am writing a simple script in Python using Selenium to detect an element by its Css selector. I am accessing the Google page, and am targeting the input, by its CSS selector, which is input[name=q]

The Chrome page opens as planned, but the issue is that it closes without actually finding the input, and throws the following error in the terminal: ERROR:shader_disk_cache.cc(237)] Failed to create shader cache entry: -2

I tried running the script when Google Chrome is closed, and even went as far as to close all the Chrome processes in Task Manager, and it still complains about the shader cache entry.

What should I do here?

My code is:

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()  

回答1:

Your code is near perfect. You need to make a small change as follows:

Edit the CSS_SELECTOR from:

fLocator = "input[name=q]" 

To:

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

Update:

Looking at the error, resurfacing of the error and some research over these few links and discussions I feel the shader_disk_cache.cc or shader_disk_cache.h somehow got corrupted. I think a clean uninstall of Google Chrome (using Revo Uninstaller) and complete disk cleanup (using CCleaner) & finally installation of the latest Google Chrome may get us beyond the error.



回答2:

I ran the script (your code) and no errors came.

Possibly the problem is of chrome driver, please make sure 32/64 bit version is not causing this issue. Also, please see the following link, it may help: "Unable to move the cache" error in selenium webdriver



回答3:

Correct Locator are

Using xpath: //*[@id='gs_htif0']

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!