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()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…