def click_visible_elements(self, selector, by=By.CSS_SELECTOR, limit=0):
        """ Finds all matching page elements and clicks visible ones in order.
            If a click reloads or opens a new page, the clicking will stop.
            Works best for actions such as clicking all checkboxes on a page.
            Example:  self.click_visible_elements('input[type="checkbox"]')
            If "limit" is set and > 0, will only click that many elements. """
        elements = self.find_elements(selector, by=by)
        count = 0
        click_count = 0
        for element in elements:
            if limit and limit > 0 and click_count >= limit:
                return
            count += 1
            if count == 1:
                self.wait_for_ready_state_complete()
                if self.is_element_visible(selector, by=by):
                    self.click(selector, by=by)
                    click_count += 1
            else:
                self.wait_for_ready_state_complete()
                try:
                    if element.is_displayed():
                        self.__scroll_to_element(element)
                        element.click()
                        click_count += 1
                except (StaleElementReferenceException, ENI_Exception):
                    self.wait_for_ready_state_complete()
                    time.sleep(0.05)
                    try:
                        if element.is_displayed():
                            self.__scroll_to_element(element)
                            element.click()
                            click_count += 1
                    except (StaleElementReferenceException, ENI_Exception):
                        return
def click_visible_elements ( self , selector , by = By . CSS_SELECTOR , limit = 0 ) : elements = self . find_elements ( selector , by = by ) count = 0 click_count = 0 for element in elements : if limit and limit > 0 and click_count >= limit : return count += 1 if count == 1 : self . wait_for_ready_state_complete ( ) if self . is_element_visible ( selector , by = by ) : self . click ( selector , by = by ) click_count += 1 else : self . wait_for_ready_state_complete ( ) try : if element . is_displayed ( ) : self . __scroll_to_element ( element ) element . click ( ) click_count += 1 except ( StaleElementReferenceException , ENI_Exception ) : self . wait_for_ready_state_complete ( ) time . sleep ( 0.05 ) try : if element . is_displayed ( ) : self . __scroll_to_element ( element ) element . click ( ) click_count += 1 except ( StaleElementReferenceException , ENI_Exception ) : return
Finds all matching page elements and clicks visible ones in order.
            If a click reloads or opens a new page, the clicking will stop.
            Works best for actions such as clicking all checkboxes on a page.
            Example:  self.click_visible_elements('input[type="checkbox"]')
            If "limit" is set and > 0, will only click that many elements.