I used this code for Clearing Text Field by Id (using Selenium with python 2.7):
from selenium.webdriver.common.keys import Keys
browser = webdriver.Chrome():
browser.get('https://www.google.com')
search = browser.find_element_by_id('lst-ib')
search.send_keys('Python 2')
search.send_keys(Keys.RETURN)
time.sleep(6)
search.clear()
time.sleep(2)
browser.close()
It gave me the error:
StaleElementReferenceException Traceback (most recent call last) in () StaleElementReferenceException: Message: stale element reference: element is not attached to the page document (Session info: chrome=65.0.3325.181) (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.16299 x86_64)
Does anyone know how to fix this