Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
omit =
**/modal/*
tests/*
32 changes: 32 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Unit tests and Coverage
on:
push:
branches:
- main
pull_request:
types: [ opened, synchronize, reopened ]

jobs:
test:
name: Unit tests and Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
playwright install
- name: Unit tests
run: coverage run -m pytest
- name: Generate Coverage Report
run: coverage xml
- name: Codacy Coverage
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/dist/
/python_a11y_playwright.egg-info/
/python_a11y_playwright_test.egg-info/
/.pytest_cache/
/.coverage
1 change: 1 addition & 0 deletions automateda11y/pw/axerunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, page):

def set_page_title(self, page_title):
self.params.set_page_title(page_title)
return self

def execute(self):
data = self.a11y.execute(Engine.AXE, self.params)
Expand Down
3 changes: 3 additions & 0 deletions automateda11y/pw/htmlcsrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ def __init__(self, page):

def set_standard(self, standard="WCAG2AA"):
self.params.set_standard(standard)
return self

def set_ignore_code(self, codes):
self.params.set_ignore_codes(codes)
return self

def set_page_title(self, page_title):
self.params.set_page_title(page_title)
return self

def execute(self):
data = self.a11y.execute(Engine.HTMLCS, self.params)
Expand Down
39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "python-a11y-playwright"
version = "0.0.2"
authors = [
{ name="Sridhar Bandi", email="sridhar.bandi.ece@gmail.com" },
]
license = {text = "MIT License"}
description = "Automate Web Accessibility Testing using AXE/HTMLCS with Playwright Python"
readme = "ReadMe.md"
requires-python = ">=3.7"
classifiers = [
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
]
keywords = ["axe", "htmlcs", "accessibility", "playwright"]
dependencies = [
"marshmallow-dataclass"
]

[project.urls]
Homepage = "https://github.com/automated-a11y/python-a11y-playwright"
repository = "https://github.com/automated-a11y/python-a11y-playwright.git"

[tool.setuptools.packages.find]
exclude = ["tests", "*.tests", "*.tests.*", "tests.*"]

[tool.setuptools.package-data]
"automateda11y.pw.resources" = ["js/*.js"]
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
playwright==1.29.1
marshmallow-dataclass==8.5.11
marshmallow~=3.19.0
pynguin~=0.30.0
pytest-playwright==0.3.0
coverage==7.1.0
41 changes: 0 additions & 41 deletions setup.py

This file was deleted.

20 changes: 0 additions & 20 deletions tests/axetest.py

This file was deleted.

20 changes: 0 additions & 20 deletions tests/htmlcstest.py

This file was deleted.

18 changes: 18 additions & 0 deletions tests/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!Doctype Html>
<Html>
<Head>
<Title>
Login form
</Title>
</Head>
<Body>
Login form:
<form>
<label>User Id: </label> <br>
<input type="text"> <br> <br>
<label>Password:</label> <br>
<input type="password"> <br> <br>
<input type="submit" value="Submit">
</form>
</Body>
</Html>
17 changes: 17 additions & 0 deletions tests/test_axe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pathlib import Path

from playwright.sync_api import Page

from automateda11y.pw.axerunner import AxeRunner
from automateda11y.pw.settings import Settings


def root_dir():
return Path(__file__).parent.parent.__str__()


def test_accessibility_axe(page: Page):
Settings.report_dir = root_dir() + '/reports'
page.goto("file://"+root_dir()+"/tests/test.html")
data = AxeRunner(page).set_page_title("Page Title").execute()
assert len(data.violations) == 2
17 changes: 17 additions & 0 deletions tests/test_htmlcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pathlib import Path

from playwright.sync_api import Page

from automateda11y.pw.htmlcsrunner import HtmlCsRunner
from automateda11y.pw.settings import Settings


def root_dir():
return Path(__file__).parent.parent.__str__()


def test_accessibility_htmlcs(page: Page):
Settings.report_dir = root_dir() + '/reports'
page.goto("file://"+root_dir()+"/tests/test.html")
data = HtmlCsRunner(page).set_standard().set_page_title("Page Title").set_ignore_code([]).execute()
assert data.errors == 5