I'm scraping a dynamic page that requires the user to click a "Load More Results" button several times in order to get all data. Is there a better way to approach the task of clicking on an element while displayed?
def clickon(xpath):
try:
element = driver.find_element_by_xpath(xpath)
except:
print "RETRYING CLICKON() for %s" % (xpath)
time.sleep(1)
clickon(xpath)
else:
element.click()
time.sleep(3)
def click_element_while_displayed(xpath):
element = driver.find_element_by_xpath(xpath)
try:
while element.is_displayed():
clickon(xpath)
except:
pass