Find and click a submit button matching the specified type.
(self, btn_type: str = 'login', timeout: int = 5)
| 593 | return False |
| 594 | |
| 595 | def find_and_click_btn(self, btn_type: str = 'login', timeout: int = 5) -> bool: |
| 596 | """Find and click a submit button matching the specified type.""" |
| 597 | buttons = self.get_buttons_xpath() |
| 598 | if not buttons: |
| 599 | self.logger.warning("No visible buttons found") |
| 600 | return False |
| 601 | |
| 602 | for button_text, xpath in buttons: |
| 603 | if btn_type.lower() in button_text.lower() or btn_type.lower() in xpath.lower(): |
| 604 | try: |
| 605 | wait = WebDriverWait(self.driver, timeout) |
| 606 | element = wait.until( |
| 607 | EC.element_to_be_clickable((By.XPATH, xpath)), |
| 608 | message=f"Button with XPath '{xpath}' not clickable within {timeout} seconds" |
| 609 | ) |
| 610 | if self.click_element(xpath): |
| 611 | self.logger.info(f"Clicked button '{button_text}' at XPath: {xpath}") |
| 612 | return True |
| 613 | else: |
| 614 | self.logger.warning(f"Button '{button_text}' at XPath: {xpath} not clickable") |
| 615 | return False |
| 616 | except TimeoutException: |
| 617 | self.logger.warning(f"Timeout waiting for '{button_text}' button at XPath: {xpath}") |
| 618 | return False |
| 619 | except Exception as e: |
| 620 | self.logger.error(f"Error clicking button '{button_text}' at XPath: {xpath} - {str(e)}") |
| 621 | return False |
| 622 | self.logger.warning(f"No button matching '{btn_type}' found") |
| 623 | return False |
| 624 | |
| 625 | def tick_all_checkboxes(self) -> bool: |
| 626 | """ |
no test coverage detected