diff --git a/Browser/browser.py b/Browser/browser.py index abf6f16a5..8b51a33f9 100755 --- a/Browser/browser.py +++ b/Browser/browser.py @@ -23,7 +23,7 @@ from concurrent.futures._base import Future from datetime import timedelta from pathlib import Path -from typing import Any, ClassVar, Optional, Union +from typing import Any, Optional, Union from assertionengine import AssertionOperator from overrides import overrides @@ -777,23 +777,6 @@ class Browser(DynamicCore): ROBOT_LISTENER_API_VERSION = 2 ROBOT_LIBRARY_LISTENER: "Browser" ROBOT_LIBRARY_SCOPE = "GLOBAL" - ERROR_AUGMENTATION: ClassVar[list[dict]] = [ - { - "re": re.compile(r"Timeout .+ exceeded."), - "callable": lambda msg: ( - f'{msg}\nTip: Use "Set Browser Timeout" for increasing the timeout or ' - "double check your locator as the targeted element(s) couldn't be found." - ), - "selector": True, - }, - { - "re": re.compile(r"Timeout .+ exceeded."), - "callable": lambda msg: ( - f'{msg}\nTip: Use "Set Browser Timeout" for increasing the timeout.' - ), - "selector": False, - }, - ] _context_cache = ContextCache() _suite_cleanup_done = False @@ -1279,19 +1262,22 @@ def _prune_execution_stack(self, catalog_before: dict) -> None: def _alter_keyword_error(self, name: str, args: tuple) -> tuple: if not (args and isinstance(args, tuple)): return args - - message = args[0] - argument_specification = self.keywords_spec[name].argument_specification - selector_in_args = "selector" in argument_specification - for augmentation in self.ERROR_AUGMENTATION: - regex, augment, selector = ( - augmentation["re"], - augmentation["callable"], - augmentation["selector"], + ansi_escape = re.compile( + r""" + \x1B # ESC + (?: # 7-bit C1 Fe (except CSI) + [@-Z\\-_] + | # or [ for CSI, followed by a control sequence + \[ + [0-?]* # Parameter bytes + [ -/]* # Intermediate bytes + [@-~] # Final byte ) - if regex.search(message) and selector == selector_in_args: - message = augment(message) - return (message,) + args[1:] + """, + re.VERBOSE, + ) + clean_message = ansi_escape.sub("", args[0]) + return (clean_message,) + args[1:] def _set_logging(self, status: bool): try: diff --git a/atest/test/01_Browser_Management/new_page_should_not_timeout.robot b/atest/test/01_Browser_Management/new_page_should_not_timeout.robot index 21e786f7d..6f89fa77c 100644 --- a/atest/test/01_Browser_Management/new_page_should_not_timeout.robot +++ b/atest/test/01_Browser_Management/new_page_should_not_timeout.robot @@ -17,7 +17,7 @@ New Page Will Timeout And Page Will Be Removed From Catalog ${Catalog} = Get Browser Catalog TRY New Page ${SLOW_PAGE} - EXCEPT *timeout* type=glob + EXCEPT *Timeout* type=glob ${new_catalog} = Get Browser Catalog Should Be Equal ${Catalog} ${new_catalog} ELSE diff --git a/atest/test/01_Browser_Management/persistent_state.robot b/atest/test/01_Browser_Management/persistent_state.robot index 92ab60a14..4cee59f03 100644 --- a/atest/test/01_Browser_Management/persistent_state.robot +++ b/atest/test/01_Browser_Management/persistent_state.robot @@ -78,7 +78,7 @@ New Persistent Context Cleaned Up After Timeout ${catalog_1} = Get Browser Catalog TRY New Persistent Context url=${SLOW_PAGE} timeout=1s - EXCEPT *timeout* type=GLOB + EXCEPT *Timeout* type=GLOB ${catalog_2} = Get Browser Catalog Should Be Equal ${catalog_1} ${catalog_2} END @@ -90,7 +90,7 @@ New Persistent Context Cleaned Up After Timeout ${catalog_3} = Get Browser Catalog TRY New Persistent Context url=${SLOW_PAGE} timeout=1s - EXCEPT *timeout* type=GLOB + EXCEPT type=GLOB ${catalog_4} = Get Browser Catalog Should Be Equal ${catalog_3} ${catalog_4} END diff --git a/atest/test/01_Browser_Management/timeout.robot b/atest/test/01_Browser_Management/timeout.robot index cb9fd4055..7d5fd7a82 100644 --- a/atest/test/01_Browser_Management/timeout.robot +++ b/atest/test/01_Browser_Management/timeout.robot @@ -5,14 +5,12 @@ Resource imports.resource Suite Setup New Browser headless=${HEADLESS} Suite Teardown Close Browser -Force Tags timeout no-iframe +Test Tags timeout no-iframe *** Variables *** ${err_goto} = page.goto: Timeout 1ms exceeded. ${err_click} = SEPARATOR= ... locator.click: Timeout 100ms exceeded. -... *Use "Set Browser Timeout" for increasing the timeout or double check${SPACE} -... your locator as the targeted element(s) couldn't be found. *** Test Cases *** Test GoTo With Short Default Timeout diff --git a/atest/test/02_Content_Keywords/dialogs.robot b/atest/test/02_Content_Keywords/dialogs.robot index 519b53ea7..406dc8791 100644 --- a/atest/test/02_Content_Keywords/dialogs.robot +++ b/atest/test/02_Content_Keywords/dialogs.robot @@ -122,7 +122,7 @@ Handle Multiple Dialogs With Wrong Texts Log Got expected error, all is good. END -Handle Conform And Prompt +Handle Conform And Prompt With Dismiss Accept [Setup] New Page ${DIALOGS_TWO_URL} ${promise} = Promise To ... Wait For Alerts @@ -138,7 +138,7 @@ Handle Conform And Prompt Get Text id=confirm == First alert declined! Get Text id=prompt == Second alert input: I am a prompt -Handle Conform And Prompt +Handle Conform And Prompt With Accept Dismiss [Setup] New Page ${DIALOGS_TWO_URL} ${promise} = Promise To ... Wait For Alerts diff --git a/atest/test/03_Waiting/wait_for_http.robot b/atest/test/03_Waiting/wait_for_http.robot index cc20cbdf7..a7649cb42 100644 --- a/atest/test/03_Waiting/wait_for_http.robot +++ b/atest/test/03_Waiting/wait_for_http.robot @@ -74,16 +74,6 @@ Wait Until Network Is Idle Works Wait Until Network Is Idle timeout=3s Get Text \#server_delayed_response == after some time I respond -Wait Until Network Is Fails And Contains Correct Tip - [Tags] slow - Go To ${ROOT_URL}delayed-load.html - Get Text \#server_delayed_response == Server response after 400ms - TRY - Wait Until Network Is Idle timeout=0.1s - EXCEPT AS ${error} - Should End With ${error} Tip: Use "Set Browser Timeout" for increasing the timeout. strip_spaces=True - END - Wait For Navigation Works [Tags] slow Go To ${ROOT_URL}redirector.html