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()
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
Correct Locator are
Using xpath:
//*[@id='gs_htif0']
fLocator =
"input[name='q']"
Your code is near perfect. You need to make a small change as follows:
Edit the
CSS_SELECTOR
from:To:
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
orshader_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.