0
0
Selenium Pythontesting~5 mins

Test reporting in CI in Selenium Python

Choose your learning style9 modes available
Introduction

Test reporting in CI helps you see if your tests passed or failed automatically after every code change. It makes sure your software stays good without checking manually.

When you want to check if new code breaks your website automatically.
When your team wants quick feedback on test results after each update.
When you want to keep a history of test results to find patterns.
When you want to share test results easily with your team.
When you want to stop bad code from going live by failing tests.
Syntax
Selenium Python
pytest --junitxml=report.xml

# Then configure your CI tool to run this command and collect report.xml

The --junitxml option creates a test report file in XML format.

CI tools like Jenkins or GitHub Actions can read this file to show test results.

Examples
This command runs tests and saves the report as results.xml.
Selenium Python
pytest --junitxml=results.xml
This runs tests inside the tests/ folder and saves the report as ci_report.xml.
Selenium Python
pytest tests/ --junitxml=ci_report.xml
Sample Program

This script opens Google in Chrome, checks the page title, and quits the browser. It runs the test with pytest and saves the report as report.xml.

Selenium Python
from selenium import webdriver
import pytest

def test_google_title():
    driver = webdriver.Chrome()
    driver.get('https://www.google.com')
    assert 'Google' in driver.title
    driver.quit()

if __name__ == '__main__':
    pytest.main(['--junitxml=report.xml'])
OutputSuccess
Important Notes

Make sure your CI environment has the browser driver installed for Selenium tests.

Use meaningful test names so reports are easy to understand.

Keep reports in a folder your CI tool can access and archive them if needed.

Summary

Test reporting in CI gives quick feedback on test results automatically.

Use pytest with --junitxml to create reports CI tools can read.

Reports help teams find and fix problems faster.