@@ -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:
@@ -8262,7 +8268,10 @@ def is_connected(self):
82628268 In CDP Mode, the CDP-Driver controls the web browser.
82638269 The CDP-Driver can be connected while WebDriver isn't.
82648270 """
8265- return self.driver.is_connected()
8271+ if hasattr(self.driver, "is_connected"):
8272+ return self.driver.is_connected()
8273+ else:
8274+ return True
82668275
82678276 def is_chromium(self):
82688277 """Return True if the browser is Chrome or Edge."""
@@ -10174,9 +10183,13 @@ def wait_for_link_text_present(self, link_text, timeout=None):
1017410183 if now_ms >= stop_ms:
1017510184 break
1017610185 time.sleep(0.2)
10177- 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!" % (
1017810190 link_text,
1017910191 timeout,
10192+ plural,
1018010193 )
1018110194 page_actions.timeout_exception("LinkTextNotFoundException", message)
1018210195
@@ -10199,9 +10212,12 @@ def wait_for_partial_link_text_present(self, link_text, timeout=None):
1019910212 if now_ms >= stop_ms:
1020010213 break
1020110214 time.sleep(0.2)
10215+ plural = "s"
10216+ if timeout == 1:
10217+ plural = ""
1020210218 message = (
10203- "Partial Link text {%s} was not found after %s seconds !"
10204- "" % (link_text, timeout)
10219+ "Partial Link text {%s} was not found after %s second%s !"
10220+ "" % (link_text, timeout, plural )
1020510221 )
1020610222 page_actions.timeout_exception("LinkTextNotFoundException", message)
1020710223
@@ -14409,9 +14425,12 @@ def __get_shadow_element(
1440914425 if must_be_visible and is_present:
1441014426 error = "not visible"
1441114427 the_exception = "ElementNotVisibleException"
14428+ plural = "s"
14429+ if timeout == 1:
14430+ plural = ""
1441214431 msg = (
14413- "Shadow DOM Element {%s} was %s after %s seconds !"
14414- % (selector_chain, error, timeout)
14432+ "Shadow DOM Element {%s} was %s after %s second%s !"
14433+ % (selector_chain, error, timeout, plural )
1441514434 )
1441614435 page_actions.timeout_exception(the_exception, msg)
1441714436 return element
0 commit comments