diff --git a/selene/core/wait.py b/selene/core/wait.py index 20d9d99e..5fc53eea 100644 --- a/selene/core/wait.py +++ b/selene/core/wait.py @@ -119,11 +119,9 @@ def logic(fn: Callable[[E], R]) -> R: return fn(self.entity) except Exception as reason: if time.time() > finish_time: - reason_message = str(reason) - reason_string = '{name}: {message}'.format( name=reason.__class__.__name__, - message=reason_message, + message=getattr(reason, "msg", str(reason)), ) # TODO: think on how can we improve logging failures in selene, e.g. reverse msg and stacktrace # stacktrace = getattr(reason, 'stacktrace', None) diff --git a/tests/integration/element__type_test.py b/tests/integration/element__type_test.py index c685f969..9f71be8f 100644 --- a/tests/integration/element__type_test.py +++ b/tests/integration/element__type_test.py @@ -161,7 +161,7 @@ def test_type_failure_when_invisible(session_browser): assert time_spent >= 1 browser.element('#text-field').should(have.value('before')) assert ( - 'Reason: JavascriptException: Message: javascript error: ' + 'Reason: JavascriptException: javascript error: ' 'element ' ' ' 'is not visible\n' diff --git a/tests/integration/error_messages_test.py b/tests/integration/error_messages_test.py index 46b99109..750d64ee 100644 --- a/tests/integration/error_messages_test.py +++ b/tests/integration/error_messages_test.py @@ -92,9 +92,10 @@ def test_element_search_fails_with_message_when_implicitly_waits_for_condition( 'Timed out after 0.1s, while waiting for:', "browser.element(('css selector', '#hidden-button')).click", '', - 'Reason: ElementNotInteractableException: Message: element not interactable', + 'Reason: ElementNotInteractableException: element not interactable', '(Session info: *)', - 'Stacktrace: *', + 'Screenshot: *.png', + 'PageSource: *.html', ] @@ -119,9 +120,10 @@ def test_inner_element_search_fails_with_message_when_implicitly_waits_for_condi "browser.element(('css selector', '#container')).element(('css selector', " "'#hidden-button')).click", '', - 'Reason: ElementNotInteractableException: Message: element not interactable', + 'Reason: ElementNotInteractableException: element not interactable', '(Session info: *)', - 'Stacktrace: *', + 'Screenshot: *.png', + 'PageSource: *.html', ] @@ -146,9 +148,10 @@ def test_inner_element_search_fails_with_message_when_implicitly_waits_for_condi "browser.element(('css selector', '#hidden-container')).element(('css " "selector', '#button')).click", '', - 'Reason: ElementNotInteractableException: Message: element not interactable', + 'Reason: ElementNotInteractableException: element not interactable', '(Session info: *)', - 'Stacktrace: *', + 'Screenshot: *.png', + 'PageSource: *.html', ] @@ -173,11 +176,12 @@ def test_inner_element_search_fails_with_message_when_implicitly_waits_for_condi "browser.element(('css selector', '#not-existing')).element(('css selector', " "'#button')).click", '', - 'Reason: NoSuchElementException: Message: no such element: Unable to locate ' + 'Reason: NoSuchElementException: no such element: Unable to locate ' 'element: {"method":"css selector","selector":"#not-existing"}', '(Session info: *); For documentation on this error, please visit: ' 'https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception', - 'Stacktrace: *', + 'Screenshot: *.png', + 'PageSource: *.html', ]