Skip to content

Commit b4595f8

Browse files
committed
Update a raw selenium example
1 parent b25534a commit b4595f8

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

examples/migration/raw_selenium/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ By this stage, newcomers to Selenium have evolved into legitimate test automatio
2929

3030
* [refined_raw.py](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/migration/raw_selenium/refined_raw.py)
3131

32-
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.
32+
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.
3333

3434
* [simple_sbase.py](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/migration/raw_selenium/simple_sbase.py)
3535

examples/migration/raw_selenium/refined_raw.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,41 @@ def tearDown(self):
3434
def wait_for_element_visible(
3535
self, selector, by="css selector", timeout=10
3636
):
37-
return WebDriverWait(self.driver, timeout).until(
38-
EC.visibility_of_element_located((by, selector))
39-
)
37+
try:
38+
return WebDriverWait(self.driver, timeout).until(
39+
EC.visibility_of_element_located((by, selector))
40+
)
41+
except Exception:
42+
raise Exception(
43+
"Element {%s} was not visible after %s seconds!"
44+
% (selector, timeout)
45+
)
4046

4147
def wait_for_element_clickable(
4248
self, selector, by="css selector", timeout=10
4349
):
44-
return WebDriverWait(self.driver, timeout).until(
45-
EC.element_to_be_clickable((by, selector))
46-
)
50+
try:
51+
return WebDriverWait(self.driver, timeout).until(
52+
EC.element_to_be_clickable((by, selector))
53+
)
54+
except Exception:
55+
raise Exception(
56+
"Element {%s} was not visible/clickable after %s seconds!"
57+
% (selector, timeout)
58+
)
4759

4860
def wait_for_element_not_visible(
4961
self, selector, by="css selector", timeout=10
5062
):
51-
return WebDriverWait(self.driver, timeout).until(
52-
EC.invisibility_of_element((by, selector))
53-
)
63+
try:
64+
return WebDriverWait(self.driver, timeout).until(
65+
EC.invisibility_of_element((by, selector))
66+
)
67+
except Exception:
68+
raise Exception(
69+
"Element {%s} was still visible after %s seconds!"
70+
% (selector, timeout)
71+
)
5472

5573
def open(self, url):
5674
self.driver.get(url)

0 commit comments

Comments
 (0)