diff --git a/tests/e2e-test/README.md b/tests/e2e-test/README.md index ea844696..1957a0d2 100644 --- a/tests/e2e-test/README.md +++ b/tests/e2e-test/README.md @@ -23,7 +23,7 @@ Installing Playwright Pytest from Virtual Environment Run test cases -- To run test cases from your 'tests' folder : "pytest --html=report.html --self-contained-html" +- To run test cases from e2e-test: "pytest --html=report.html --self-contained-html" Create .env file in project root level with web app url and client credentials diff --git a/tests/e2e-test/requirements.txt b/tests/e2e-test/requirements.txt index 1b0ac0d7..37159fb1 100644 --- a/tests/e2e-test/requirements.txt +++ b/tests/e2e-test/requirements.txt @@ -4,3 +4,4 @@ python-dotenv pytest-check pytest-html py +beautifulsoup4 diff --git a/tests/e2e-test/tests/conftest.py b/tests/e2e-test/tests/conftest.py index 5823badc..28771989 100644 --- a/tests/e2e-test/tests/conftest.py +++ b/tests/e2e-test/tests/conftest.py @@ -9,6 +9,8 @@ from py.xml import html # type: ignore import io import logging +from bs4 import BeautifulSoup +import atexit @pytest.fixture(scope="session") @@ -83,4 +85,29 @@ def pytest_collection_modifyitems(items): if hasattr(item, 'callspec'): prompt = item.callspec.params.get("prompt") if prompt: - item._nodeid = prompt # This controls how the test name appears in the report \ No newline at end of file + item._nodeid = prompt # This controls how the test name appears in the report + +def rename_duration_column(): + report_path = os.path.abspath("report.html") # or your report filename + if not os.path.exists(report_path): + print("Report file not found, skipping column rename.") + return + + with open(report_path, 'r', encoding='utf-8') as f: + soup = BeautifulSoup(f, 'html.parser') + + # Find and rename the header + headers = soup.select('table#results-table thead th') + for th in headers: + if th.text.strip() == 'Duration': + th.string = 'Execution Time' + #print("Renamed 'Duration' to 'Execution Time'") + break + else: + print("'Duration' column not found in report.") + + with open(report_path, 'w', encoding='utf-8') as f: + f.write(str(soup)) + +# Register this function to run after everything is done +atexit.register(rename_duration_column) \ No newline at end of file