diff --git a/examples/migration/raw_selenium/ReadMe.md b/examples/migration/raw_selenium/ReadMe.md index fbe39845..851847f0 100644 --- a/examples/migration/raw_selenium/ReadMe.md +++ b/examples/migration/raw_selenium/ReadMe.md @@ -29,7 +29,7 @@ By this stage, newcomers to Selenium have evolved into legitimate test automatio * [refined_raw.py](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/migration/raw_selenium/refined_raw.py) -By now, the test automation engineer has become an expert in breaking out code into reusable methods, and the test itself has been simplified down to a single page action per line. The code is easy to read and easy to maintain. The journey of writing a complete test automation framework for Selenium has begun. +By now, the test automation engineer has become an expert in breaking out code into reusable methods, and the test itself has been simplified down to a single page action per line. The code is easy to read and easy to maintain. The error output is also simplified. The journey of writing a complete test automation framework for Selenium has begun. * [simple_sbase.py](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/migration/raw_selenium/simple_sbase.py) diff --git a/examples/migration/raw_selenium/refined_raw.py b/examples/migration/raw_selenium/refined_raw.py index 316ee936..84364063 100644 --- a/examples/migration/raw_selenium/refined_raw.py +++ b/examples/migration/raw_selenium/refined_raw.py @@ -34,23 +34,41 @@ class RefinedRawSelenium(TestCase): def wait_for_element_visible( self, selector, by="css selector", timeout=10 ): - return WebDriverWait(self.driver, timeout).until( - EC.visibility_of_element_located((by, selector)) - ) + try: + return WebDriverWait(self.driver, timeout).until( + EC.visibility_of_element_located((by, selector)) + ) + except Exception: + raise Exception( + "Element {%s} was not visible after %s seconds!" + % (selector, timeout) + ) def wait_for_element_clickable( self, selector, by="css selector", timeout=10 ): - return WebDriverWait(self.driver, timeout).until( - EC.element_to_be_clickable((by, selector)) - ) + try: + return WebDriverWait(self.driver, timeout).until( + EC.element_to_be_clickable((by, selector)) + ) + except Exception: + raise Exception( + "Element {%s} was not visible/clickable after %s seconds!" + % (selector, timeout) + ) def wait_for_element_not_visible( self, selector, by="css selector", timeout=10 ): - return WebDriverWait(self.driver, timeout).until( - EC.invisibility_of_element((by, selector)) - ) + try: + return WebDriverWait(self.driver, timeout).until( + EC.invisibility_of_element((by, selector)) + ) + except Exception: + raise Exception( + "Element {%s} was still visible after %s seconds!" + % (selector, timeout) + ) def open(self, url): self.driver.get(url)