The site is https://www.webstaurantstore.com/25887/commercial-gas-ranges.html?page=1 . When I want to localize the search field in the top right corner and send then keys there, it works. But when I want to do the same operation after executing one search it does not work. selenium can locate element, but can not send keys to it. Why something like this happening and how can I avoid that?
while True:
try:
a = self.webdriver.find_element_by_xpath('/html/body/div[3]/div[1]/div[2]/div[2]/div/div[2]/div/form/div/input')
except:
pass
else:
a.send_keys(i.text[1:])
break
Error:
>>>selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
(Session info: chrome=81.0.4044.138)