while True:
try:
driver.find_element_by_id('').click()
break
except:
try:
scroll()
driver.find_element_by_id('').click()
break
except:
scroll()
I want to scroll until I find the element and click it
Can't we make it an if or for statement instead of making an exception?What is the best way?
python exception-handling
Try the recursive function that calls and repeats itself. If you change the code below and apply it properly, it will work as you intended.
def click(toClick):
try:
driver.find_element_by_id(toClick).click()
return
except:
scroll()
click(toClick)
© 2024 OneMinuteCode. All rights reserved.