File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Unit Tests
1+ name : Reporterplus marketplace actions test
22
33on :
44 pull_request :
2323 with :
2424 python-version : ${{ matrix.python-version }}
2525
26- - name : 🧪 Run tests with coverage
26+ - name : 🧪 Run selenium test and generate report using marketplace plugin
2727 uses : reporterplus/pytest-html-plus-action@v1
2828 with :
29- pytest-args : " --cov=pytest_html_plus tests/ --cov-fail-under=75 --cov-report=term --reruns 1"
30-
29+ pytest-args : " --cov=pytest_html_plus tests/e2e/test_selenium.py --cov-report=term --reruns 1"
30+ html-output : " report_output_selenium"
31+ capture-screenshots : " all"
32+ test-path : " tests/browser/test_selenium.py"
33+
34+ - name : 🧪 Run selenium test and generate report using marketplace plugin
35+ uses : reporterplus/pytest-html-plus-action@v1
36+ with :
37+ pytest-args : " --cov=pytest_html_plus --cov-report=term --reruns 1"
38+ html-output : " report_output_playwright"
39+ capture-screenshots : " all"
40+ test-path : " tests/browser/test_playwright.py"
41+
42+ - name : Upload reports
43+ uses : actions/upload-artifact@v4
44+ with :
45+ name : reports-${{ github.job }}-${{ github.run_number }}-${{ matrix.python-version }}
46+ path : |
47+ report_output_playwright/
48+ report_output_selenium/
49+
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ pytest-cov = "^6.2.1"
4747playwright = " ^1.53.0"
4848pytest-playwright = " ^0.7.0"
4949pytest-xdist = " ^3.8.0"
50+ selenium>=4.8.0
51+ webdriver-manager>=3.8.5
5052
5153[build-system ]
5254requires = [" poetry-core" ]
Original file line number Diff line number Diff line change 1+ def test_example_com (page ):
2+ # `page` is provided by pytest-playwright
3+ page .goto ("https://example.com" )
4+ assert "Example Domainn" in page .content ()
Original file line number Diff line number Diff line change 1+ # tests/test_example_selenium.py
2+ import os
3+ from selenium import webdriver
4+ from selenium .webdriver .chrome .service import Service
5+ from selenium .webdriver .chrome .options import Options
6+ from webdriver_manager .chrome import ChromeDriverManager
7+ import time
8+
9+
10+ def make_driver (request ):
11+ chrome_options = Options ()
12+ # headless mode
13+ chrome_options .add_argument ("--headless=new" )
14+ chrome_options .add_argument ("--no-sandbox" )
15+ chrome_options .add_argument ("--disable-dev-shm-usage" )
16+ chrome_options .add_argument ("--disable-gpu" )
17+ chrome_options .add_argument ("--window-size=1280,1024" )
18+ svc = Service (ChromeDriverManager ().install ())
19+ drv = webdriver .Chrome (service = svc , options = chrome_options )
20+ request .node .page_for_screenshot = drv
21+
22+ # using webdriver-manager to install the chromedriver binary
23+ service = Service (ChromeDriverManager ().install ())
24+ driver = webdriver .Chrome (service = service , options = chrome_options )
25+ return driver
26+
27+ def test_example_dot_com_screenshot (request ):
28+ driver = make_driver (request )
29+ try :
30+ url = "https://example.com"
31+ driver .get (url )
32+ time .sleep (10 )
33+ assert "Example Domainn" in driver .page_source
34+ finally :
35+ driver .quit ()
You can’t perform that action at this time.
0 commit comments