Skip to content

Commit d21f1a0

Browse files
authored
Merge pull request #38 from reach2jeyan/37-screenshot-not-attached-in-selenium
Bug fixes
2 parents 9f31b5f + 5c7ae7c commit d21f1a0

4 files changed

Lines changed: 51 additions & 21 deletions

File tree

README.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ You’ll get:
2828

2929
report.html – a clean, styled HTML report
3030

31+
---
32+
## Available Options
33+
| Option | Description | Default | Choices |
34+
| ----------------------- | ------------------------------------------------------------------ | ------------------------ |----------------------------------|
35+
| `--json-report` | Path to save individual JSON test reports | `playwright_report.json` | *Any valid file path* |
36+
| `--automation-tool` | Specify automation tool used for testing | `playwright` | `playwright`, `selenium`, `other` |
37+
| `--capture-screenshots` | When to capture screenshots | `failed` | `failed`, `all`, `none` |
38+
| `--html-output` | Directory to output HTML reports | `report_output` | *Any valid directory* |
39+
| `--screenshots` | Directory where screenshots will be stored | `screenshots` | *Any valid directory* |
40+
| `--send-email` | Send HTML report via email after the test run | `False` | `True`, `False` |
3141
---
3242

3343
## ✨ Features
@@ -71,28 +81,12 @@ Just start typing, and the dashboard will instantly filter tests by:
7181

7282
![Screen Recording 2025-06-01 at 2 48 08 PM](https://github.com/user-attachments/assets/057441ac-06a3-421f-aafc-915968a90463)
7383

74-
75-
76-
77-
---
78-
7984
## Why use pytest-reporter-plus?
8085
Stop wasting time writing and maintaining custom pytest reporter hooks like pytest_runtest_makereport!
8186
With pytest-reporter-plus, you get a beautiful, lightweight HTML report out of the box — no extra coding needed.
8287

8388
Just install, run your tests, and let the plugin handle all the reporting magic. Focus on what matters: writing and running your tests.
8489

85-
## Available Options
86-
| Option | Description | Default | Choices |
87-
| ----------------------- | ------------------------------------------------------------------ | ------------------------ | ------------------------ |
88-
| `--json-report` | Path to save individual JSON test reports | `playwright_report.json` | *Any valid file path* |
89-
| `--automation-tool` | Specify automation tool used for testing | `playwright` | `playwright`, `selenium` |
90-
| `--capture-screenshots` | When to capture screenshots | `failed` | `failed`, `all`, `none` |
91-
| `--html-output` | Directory to output HTML reports | `report_output` | *Any valid directory* |
92-
| `--screenshots` | Directory where screenshots will be stored | `screenshots` | *Any valid directory* |
93-
| `--send-email` | Send HTML report via email after the test run | `False` | `True`, `False` |
94-
| `--detect-flake` | Detect flaky tests based on reruns in the current or last few runs | `False` | `True`, `False` |
95-
9690

9791
## 🔁 Flaky Test Detection
9892
If a test is retried multiple times (e.g. due to a --reruns plugin), the report will flag it as FLAKY.
@@ -103,9 +97,8 @@ In the HTML report, you’ll see a badge like:
10397

10498

10599
## 📧 Email Report (Optional)
106-
Send the HTML report via email using --send-email.
100+
Send the HTML report via email using --send-email. Please note you will need your own sendgrid setup to use this feature
107101

108-
### Setup Environment Variables
109102
Create an emailenv file in your project folder that has the following
110103

111104
```commandline

pyproject.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
[tool.poetry]
22
name = "pytest-reporter-plus"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
description = "Lightweight enhanced HTML reporter for Pytest"
55
readme = "README.md"
66
authors = ["Emjey","Karan"]
77
license = "MIT"
88
packages = [{ include = "pytest_reporter_plus" }]
9+
keywords = [
10+
"html",
11+
"pytest",
12+
"report",
13+
]
14+
15+
urls.Homepage = "https://github.com/reach2jeyan/pytest-report-plus"
16+
urls.Source = "https://github.com/reach2jeyan/pytest-report-plus"
17+
urls.Tracker = "https://github.com/reach2jeyan/pytest-report-plus/issues"
918

1019
[tool.poetry.dependencies]
1120
python = ">=3.9"

pytest_reporter_plus/plugin.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ def pytest_runtest_makereport(item, call):
5858
or getattr(item, "page_for_screenshot", None)
5959
)
6060
if driver:
61-
screenshot_path = take_screenshot_on_failure(item, driver)
61+
if tool == "playwright":
62+
screenshot_path = take_screenshot_on_failure(item, driver)
63+
elif tool == "selenium":
64+
screenshot_path = take_screenshot_selenium(item, driver)
65+
else:
66+
pass
6267
reporter = config._json_reporter
6368
worker_id = os.getenv("PYTEST_XDIST_WORKER") or "main"
6469
reporter.log_result(
@@ -178,7 +183,7 @@ def pytest_addoption(parser):
178183
"--automation-tool",
179184
action="store",
180185
default="playwright",
181-
choices=["selenium", "playwright"],
186+
choices=["selenium", "playwright", "other"],
182187
help="Specify automation tool: selenium (default) or playwright"
183188
)
184189
parser.addoption(

tests/selenium_initial_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
from selenium import webdriver
3+
from selenium.webdriver.chrome.options import Options
4+
from selenium.webdriver.common.by import By
5+
import os
6+
7+
@pytest.fixture(scope="function")
8+
def driver():
9+
options = Options()
10+
options.add_argument('--headless')
11+
options.add_argument('--no-sandbox')
12+
driver = webdriver.Chrome(options=options)
13+
yield driver
14+
driver.quit()
15+
16+
def test_title_should_pass(driver):
17+
driver.get("https://example.com")
18+
assert "Example Domain" in driver.title
19+
20+
def test_text_should_fail(driver):
21+
driver.get("https://example.com")
22+
elem = driver.find_element(By.TAG_NAME, "h1")
23+
assert elem.text == "Not the correct heading" # This will fail

0 commit comments

Comments
 (0)