Skip to main content

pyhtmlreport

Often open source Test Automation projects lack a good reporting solution, pyhtmlreport solves that by creating HTML reports and represents the output as steps with screenshots.

Requirements

  • Requires Python 3.7 or higher.
  • Access to Internet, materlizecss (https://materializecss.com/) is used to style the html report and accessed via cdn.

How to Install

pip install pyhtmlreport

Getting Started Guide

Once you have installed pyhtmlreport - how do you get started?

  • Import the Report class and create a Report instance.
  • Call the setup method.
    Parameters
    • Report Folder: Root report folder to contain all test reports.
    • Module Name: Name of the application, a module within the application or a function.
    • Release Name: Application Release cycle.
    • Maximum Screenshots: By default, the number of screenshots for a Report instance is 1000. This parameter can be used to increase the number.
    • Selenium Webdriver: Screenshots are taken using the pillow library. If an instance of Selenium Webdriver is provided, the brower viewport is taken as screenshot using Selenium's save_screenshot method.
  • Start writing to the test report by using the write_step method. The first step should have the Start status, it signals the start of a test to the report instance.
    Parameters
    • Step: Description (Expected or Actual Step Description).
    • Status: Start, Pass, Fail and Warn.
    • Screenshot: Optional flag to capture screenshot for a step.
  • Call the generate_report method at the end to generate the HTML report.
from pyhtmlreport import Report
from selenium.webdriver import Chrome
from selenium.webdriver.common.keys import Keys

report = Report()
driver = Chrome()

report.setup(
	report_folder=r'D:\Automation\Reports',
	module_name='Google',
	release_name='Release 1',
	selenium_driver=driver
)
driver.get('https://www.google.com/')

try:
    # Start of Test
    report.write_step(
    	'Testing Search functionality',
    	status=report.status.Start,
    	test_number=1
    )
    search_box = driver.find_element_by_css_selector('input[aria-label="Search"]')
    search_box.send_keys('pyhtmlreport is Awesome')
    search_box.send_keys(Keys.ENTER)

    # Test Steps
    results = driver.find_elements_by_css_selector('div[id="search"] div[class="g"]')
    assert len(results) > 1
    report.write_step(
    	'Google Search returned more than 1 results',
    	status=report.status.Pass,
    	screenshot=True
    )
except AssertionError:
    report.write_step(
        'Google Search did not return any result',
	 status=report.status.Fail,
	 screenshot=True
    )
except Exception as e:
    report.write_step(
        f'Something went wrong during execution!</br>{e}',
        status=report.status.Warn,
	screenshot=True
    )
finally:
    report.generate_report()
    driver.quit()

Metadata

Release files for pyhtmlreport 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyhtmlreport 1.1
File Size Uploaded Provenance Actions
pyhtmlreport-1.1.tar.gz 11.7 kB Without provenance Details for pyhtmlreport-1.1.tar.gz

Release files / pyhtmlreport-1.1.tar.gz

Download URL pyhtmlreport-1.1.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8ef1a392f459fa1afdbea00706e87431d1bad3535a1e344202673f8b110345bf
BLAKE2b-256 checksum
How to use checksums
8a9c72585fd8a5c6e3d025c600b58db97f4b93d432fb8803555774bccdc19429
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Security for pyhtmlreport 1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page