Skip to content

Commit 06babf4

Browse files
committed
Update error messages to handle a 1-second timeout
1 parent 55879ef commit 06babf4

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7678,10 +7678,13 @@ def assert_downloaded_file(self, file, timeout=None, browser=False):
76787678
break
76797679
time.sleep(1)
76807680
if not found and not os.path.exists(downloaded_file_path):
7681+
plural = "s"
7682+
if timeout == 1:
7683+
plural = ""
76817684
message = (
76827685
"File {%s} was not found in the downloads folder {%s} "
7683-
"after %s seconds! (Or the download didn't complete!)"
7684-
% (file, df, timeout)
7686+
"after %s second%s! (Or the download didn't complete!)"
7687+
% (file, df, timeout, plural)
76857688
)
76867689
page_actions.timeout_exception("NoSuchFileException", message)
76877690
if self.recorder_mode and self.__current_url_is_recordable():
@@ -7735,10 +7738,13 @@ def assert_downloaded_file_regex(self, regex, timeout=None, browser=False):
77357738
break
77367739
time.sleep(1)
77377740
if not found:
7741+
plural = "s"
7742+
if timeout == 1:
7743+
plural = ""
77387744
message = (
77397745
"Regex {%s} was not found in the downloads folder {%s} "
7740-
"after %s seconds! (Or the download didn't complete!)"
7741-
% (regex, df, timeout)
7746+
"after %s second%s! (Or the download didn't complete!)"
7747+
% (regex, df, timeout, plural)
77427748
)
77437749
page_actions.timeout_exception("NoSuchFileException", message)
77447750
if self.demo_mode:
@@ -10177,9 +10183,13 @@ def wait_for_link_text_present(self, link_text, timeout=None):
1017710183
if now_ms >= stop_ms:
1017810184
break
1017910185
time.sleep(0.2)
10180-
message = "Link text {%s} was not found after %s seconds!" % (
10186+
plural = "s"
10187+
if timeout == 1:
10188+
plural = ""
10189+
message = "Link text {%s} was not found after %s second%s!" % (
1018110190
link_text,
1018210191
timeout,
10192+
plural,
1018310193
)
1018410194
page_actions.timeout_exception("LinkTextNotFoundException", message)
1018510195

@@ -10202,9 +10212,12 @@ def wait_for_partial_link_text_present(self, link_text, timeout=None):
1020210212
if now_ms >= stop_ms:
1020310213
break
1020410214
time.sleep(0.2)
10215+
plural = "s"
10216+
if timeout == 1:
10217+
plural = ""
1020510218
message = (
10206-
"Partial Link text {%s} was not found after %s seconds!"
10207-
"" % (link_text, timeout)
10219+
"Partial Link text {%s} was not found after %s second%s!"
10220+
"" % (link_text, timeout, plural)
1020810221
)
1020910222
page_actions.timeout_exception("LinkTextNotFoundException", message)
1021010223

@@ -14412,9 +14425,12 @@ def __get_shadow_element(
1441214425
if must_be_visible and is_present:
1441314426
error = "not visible"
1441414427
the_exception = "ElementNotVisibleException"
14428+
plural = "s"
14429+
if timeout == 1:
14430+
plural = ""
1441514431
msg = (
14416-
"Shadow DOM Element {%s} was %s after %s seconds!"
14417-
% (selector_chain, error, timeout)
14432+
"Shadow DOM Element {%s} was %s after %s second%s!"
14433+
% (selector_chain, error, timeout, plural)
1441814434
)
1441914435
page_actions.timeout_exception(the_exception, msg)
1442014436
return element

0 commit comments

Comments
 (0)