I try to scrape this site by Selenium.
I want to click in \"Next Page\" buttom, for this I do:
driver.find_element_by_class_name(\'pagination-r\').c
I have written logic to handle these type of exception .
def find_element_click(self, by, expression, search_window=None, timeout=32, ignore_exception=None,
poll_frequency=4):
"""It find the element and click then handle all type of exception during click
:param poll_frequency:
:param by:
:param expression:
:param timeout:
:param ignore_exception:list It is a list of exception which is need to ignore.
:return:
"""
if ignore_exception is None:
ignore_exception = []
ignore_exception.append(NoSuchElementException)
if search_window is None:
search_window = self.driver
end_time = time.time() + timeout
while True:
try:
web_element = search_window.find_element(by=by, value=expression)
web_element.click()
return True
except tuple(ignore_exception) as e:
self.logger.debug(str(e))
if time.time() > end_time:
self.logger.exception(e)
time.sleep(poll_frequency)
break
except Exception as e:
raise
return False