a11y-checker

Web Accessibility Evaluation Library in Erlang

View the Project on GitHub antiapuentes/a11y-checker

a11y-checker is a Web Accessibility Evaluation library written in Erlang, that tests web pages for conformance to the Web Content Accessibility Guidelines 2.0 defined by the W3C, also know as WGAC 2.0, that define a serie of rules that web pages should follow to be considered accessible. The library provides test of conformance for the level A of the WCAG 2.0 in HTML, allowing to:

It was designed in a way that eases the addition of new levels of conformance and technologies to test.

During the development process, Property-based testing was used to verify the HTML techniques, making use of the PropEr tool. An automated, random HTML generator was implemented during the testing phase.

a11y-checker, its Property-based tests and its automatic random HTML generator are licensed under GPLv3.

Requirements

Installation

a11y-checker comes with an EMakefile you can use to compile the modules that compose the library by typing inside an Erlang console:

cd("path to the project").
make:all().

To load the modules that compose a11y-checker, type inside the Erlang console:

cd(ebin).
l(wcag_2).
l(html_wcag2).
l(html_techniques).

If you are interested in trying the Property-based tests, also load:

l(html_prop).
l(html_gen).

and the PropEr modules:

l(proper).
l(proper_gen).

Once you have done this, you will have access to the APIs defined by the different modules. You can find examples of use in the next section.

Usage

a11y-checher is composed by several Erlang modules, each of one providing different APIs.

Those modules are:

wcag_2

Test levels of conformance and individual success criteria for different technologies.

Functions

conformance_level(LevelOfConformance, TechnologyList, Content, EntryType) -> boolean()

success_criterion(LevelOfConformance, TechnologyList, Content, EntryType) -> boolean()

functions of the last type look like success_criterion_n_n_n_description being the n the nomenclature given by the WCGA 2.0.

Parameters

Output

Example

wcag_2:conformance_level(a, [html], "<html><head>Ejemplo</head><body><img>imagen</img></body></html>", string).

Output: (success messages are omitted for brevity)

Failing element: [{html,1},{body,2},{img,1}]
HTML H37: failed
Failing element: [{html,1},{body,2},{img,1}]
HTML H67: failed
Success Criterion 1.1.1: failed
.......
HTML H25: failed
Success Criterion 2.4.2: failed
.......
HTML H57: failed
Success Criterion 3.1.1: failed
.......
{validation_error,{error_missing_element_declaration_in_DTD,html}
HTML H88: failed
Success Criterion 4.1.1: failed
Success Criterion 4.1.2: failed
......
Level A of Conformance: denied
false

Explanation:

html_wcag2

Tests if a certain success criterion is met by the HTML of the page, for a certain level of conformance.

Its functionality is equivalent to the one provided by the wcag_2:success_criterion functions, because the technology currently supported is HTML.

html_tech

Tests if a certain HTML Technique is correctly applied by the web content.

Functions

success_criterion_n(XmlElement) -> boolean()

named following the nomenclature used by the WCAG 2.0 (Hnum), plus a brief description of the technique.

Parameters

Output

Example

Testing H37 HTML technique:

html_tech:h37_only_well_formed_images(html_tech:scan("<html><head>Example</head><body><img>Image</img></body></html>", string)).

Output:

false

The image doesn't contain a textual alternative.

Property-based tests

There are two modules related to the Property-based tests. To try them you have to get PropEr installed.

html_gen

Automatic and random HTML generator.

Example

Generate random HTML:

proper_gen:pick(html_gen:html()).

More information about proper_gen:pick and proper_gen.

html_prop

Defines the properties that the HTML Techniques should follow.

Example

Test the property related to (H37) over randomly generated HTML:

proper:quickcheck(html_prop:prop_well_formed_images()).

Proper looks for counterexamples (HTML code) where the property fails and provides an shrinked counterexample.

More information about PropEr here.

Known issues