There are ways to wait for an object e.g. a button to be clickable in selenium python. I use time.sleep()
and/or WebDriverWait...until
, it works fine.<
I come up with this:
def myClick(by, desc):
wait = WebDriverWait(dr, 10)
by = by.upper()
if by == 'XPATH':
wait.until(EC.element_to_be_clickable((By.XPATH, desc))).click()
if by == 'ID':
wait.until(EC.element_to_be_clickable((By.ID, desc))).click()
if by == 'LINK_TEXT':
wait.until(EC.element_to_be_clickable((By.LINK_TEXT, desc))).click()
with this function, the code:
driver.find_element_by_link_text('Show Latest Permit').click()
will be
myClick('link_text', 'Show Latest Permit')
instead.
I have run a couple weeks with hundreds of elements to click, I have not seen the errors any longer.