Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
686 views
in Technique[技术] by (71.8m points)

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

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:Python27chromedriver.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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...