def _call_selenium(self, method_name, retry, *args, **kwargs): """ A wrapper that catches common exceptions and handles them """ exception = None retry_call = False result = None try: method = getattr(self, method_name) result = method(*args, **kwargs) except ElementNotFound as e: # Retry once if we fail to find an element if retry is True: retry_call = True else: exception = e except StaleElementReferenceException as e: # Retry once if we encounter a stale element if retry is True: retry_call = True else: exception = e except WebDriverException as e: if "Other element would receive the click" in e.message: if retry is True: retry_call = True else: exception = e else: exception = e except ElementNotInteractableException as e: if retry is True: retry_call = True else: exception = e except Exception as e: exception = e if exception: self.selenium.capture_page_screenshot() if self.debug: self.selenium.log_source() from cumulusci.robotframework.utils import set_pdb_trace set_pdb_trace() raise e else: raise e if retry_call: self.builtin.log("Retrying call to method {}".format(method_name), level="WARN") return self._call_selenium(method_name, False, *args, **kwargs) return result
def debug(self): """Pauses execution and enters the Python debugger.""" set_pdb_trace()
def __exit__(self, exc_type, exc_val, exc_tb): if exc_val and isinstance(exc_val, Exception): set_pdb_trace(pm=True) return orig_exit(self, exc_type, exc_val, exc_tb)
def debug(self): """Pauses execution and enters the Python debugger.""" set_pdb_trace()
def __exit__(self, exc_type, exc_val, exc_tb): if exc_val and isinstance(exc_val, Exception): set_pdb_trace(pm=True) return orig_exit(self, exc_type, exc_val, exc_tb)
def _call_selenium(self, method_name, retry, *args, **kwargs): """ A wrapper that catches common exceptions and handles them """ exception = None retry_call = False # If at a new url, call self._handle_current_page() to inject JS into # the page to handle Lightning events current_page = self.selenium.get_location() if current_page != self.current_page: self.current_page = current_page self._handle_page_load() result = None try: self._wait_until_loading_is_complete() method = getattr(self, method_name) result = method(*args, **kwargs) except ElementNotFound as e: # Retry once if we fail to find an element if retry is True: retry_call = True else: exception = e except StaleElementReferenceException as e: # Retry once if we encounter a stale element if retry is True: retry_call = True else: exception = e except WebDriverException as e: if 'Other element would receive the click' in e.message: if retry is True: retry_call = True else: exception = e else: exception = e except ElementNotInteractableException as e: if retry is True: retry_call = True else: exception = e except Exception as e: exception = e if exception: self.selenium.capture_page_screenshot() if self.debug: self.selenium.log_source() from cumulusci.robotframework.utils import set_pdb_trace set_pdb_trace() raise e else: raise e if retry_call: self.builtin.log('Retrying call to method {}'.format(method_name), level='WARN') self._call_selenium(method_name, False, *args, **kwargs) return result