diff --git a/app-testing/tests/protocol_analyze_test.py b/app-testing/tests/protocol_analyze_test.py index 53530e46579..1eb1d5e10b4 100644 --- a/app-testing/tests/protocol_analyze_test.py +++ b/app-testing/tests/protocol_analyze_test.py @@ -10,6 +10,7 @@ from automation.pages.protocol_landing import ProtocolLanding from rich.console import Console from selenium.webdriver.chrome.webdriver import WebDriver +from selenium.webdriver.remote.webelement import WebElement def _what_protocols() -> list[Protocol]: @@ -39,6 +40,13 @@ def _what_protocols() -> list[Protocol]: return tests +def get_error_text(protocol_landing: ProtocolLanding, error_link: WebElement) -> str: + protocol_landing.base.click_webelement(error_link) + error_details = protocol_landing.get_popout_error().text + protocol_landing.click_popout_close() + return error_details + + @pytest.mark.parametrize( "protocol", _what_protocols(), @@ -91,26 +99,12 @@ def test_analyses( ), f"Analysis took more than {analysis_timeout} seconds." # look for analysis error if the protocol should have one + error_link = protocol_landing.get_error_details_safe() if protocol.app_error: - error_link = protocol_landing.get_error_details_safe() - assert error_link is not None, "No analysis error but was expecting one." - protocol_landing.base.click_webelement(error_link) - error_details = protocol_landing.get_popout_error().text - try: - assert error_details == protocol.app_analysis_error - except AssertionError: - raise - finally: - protocol_landing.click_popout_close() - else: - error_link = protocol_landing.get_error_details_safe() - - if error_link is not None: - protocol_landing.base.click_webelement(error_link) - error_details = protocol_landing.get_popout_error().text - protocol_landing.click_popout_close() - raise AssertionError(f"Unexpected analysis error: {error_details}") + assert get_error_text(protocol_landing, error_link) == protocol.app_analysis_error + elif error_link is not None: + raise AssertionError(f"Unexpected analysis error: {get_error_text(protocol_landing, error_link)}") # Verifying elements on Protocol Landing Page # todo fix next line needs to be safe and print name not found