Skip to content

Commit e698656

Browse files
Use relative paths for screenshots in test reports
1 parent 68eee2f commit e698656

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tests/e2e-test/tests/conftest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ def pytest_runtest_makereport(item, call):
6767
if not hasattr(report, 'extra'):
6868
report.extra = []
6969

70-
# Add screenshot as a file URL that will work when report is opened in browser
71-
# Convert to absolute path and then to file URL
72-
absolute_path = os.path.abspath(screenshot_path)
73-
file_url = f"file:///{absolute_path.replace(os.sep, '/')}"
70+
# Use relative path for screenshots to work in the Test-Report folder structure
71+
relative_screenshot_path = f"../screenshots/{screenshot_name}"
7472

7573
# pytest-html expects this format for extras
76-
report.extra.append(extras.url(file_url, name='Screenshot'))
74+
report.extra.append(extras.url(relative_screenshot_path, name='Screenshot'))
7775

7876
logging.info("Screenshot saved: %s", screenshot_path)
7977
except Exception as exc: # pylint: disable=broad-exception-caught

0 commit comments

Comments
 (0)