API Reference for hamcrest

Link to API Reference for hamcrest copied to clipboard

Reference for types provided by the hamcrest package.

The IsAccessible and IsAuditedForAccessibility classes provide primary functionality.

com.deque.html.axedevtools.matchers.AxeDevtoolsMatcher extends TypeSafeMatcher<AxeDriver>

Base AxeDevToolsMatcher class. Child classes such as IsAccessible or IsAuditedForAccessibility should be used more commonly.

AxeDevtoolsMatcher within(final String... cssSelectors)

Add CSS selectors to the context checked during an accessibility test.

cssSelectors: CSS selectors representing the context.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher within(final Selector... selectors)

Add Selectors to the context checked during an accessibility test.

selectors: Selectors representing the context.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher excluding(final String... cssSelectors)

Exclude CSS selectors from the context checked during an accessibility test.

cssSelectors: CSS selectors representing the context.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher excluding(final Selector... selectors)

Exclude Selectors from the context checked during an accessibility test.

selectors: Selectors representing the context.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher accordingTo(final String... tags)

According to accessibility tags. Check only specified accessibility tags. This option is incompatible with checkingOnly. See Rule Descriptions.

tags: List of tags for checking.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher checkingOnly(final String... rules)

Checking only accessibility rules. This option is incompatible with accordingTo. See Rule Descriptions.

rules: List of rules for checking.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher checking(final String... rules)

Check accessibility rules. In addition to given tags, also check certain rules. See Rule Descriptions.

rules: List of rules for checking.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher skipping(final String... rules)

Skipping accessibility rules. From within the given tags, skip checking of certain rules. See Rule Descriptions.

rules: List of rules for checking.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher ignoring(final String selector, final String ruleId)

Ignore violations for a selector and a given rule id.

selector: Selector produced by axe accessibility check.

ruleId: Rule Id to ignore for the given selector.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher forConfig(final URL auditPath)

Provide an audit suite by it's URL.

auditPath: the URL associated with the audit suite.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher forConfig(final String auditPath) throws MalformedURLException

Provide an audit suite by it's location on the file system.

auditPath: The absolute file path of the audit suite. Returns AxeDevtoolsMatcher for method chaining. Throws MalformedURLException if audit path is an invalid filesystem path.

AxeDevtoolsMatcher logResults(final AxeReportingOptions reportingOptions)

Log results of the accessibility check upon completion.

reportingOptions: Options defining serialization and persistence of the accessibility check.

Returns AxeDevtoolsMatcher for method chaining.

AxeDevtoolsMatcher forRuleset(final String rulesetId)

Specify a ruleset for the accessibility check. Configuring an audit suite will modify the specified ruleset. See Rulesets.

rulesetId: The id of the ruleset for configuration.

Returns AxeDevtoolsMatcher for method chaining.

com.deque.html.axedevtools.matchers.IsAccessible extends AxeDevtoolsMatcher

Perform an axe accessibility check.

  • Perform accessibility check:
    • assertThat(page, isAxeClean())
  • Define the context using: (Check the entire document by not using any of these)
    • within(String...)
    • within(Selector...)
    • excluding(String...)
    • excluding(Selector...)
  • Define the options using: (Check all rules defined by axe standards by skipping this step)
    • accordingTo(String...)
    • checkingOnly(String...)
    • checking(String...)
    • skipping(String...)
  • Define the configuration of your audit suite: (Use the default audit configuration location by skipping this step)
    • forConfig(URL)
    • forConfig(String)
  • Define the logging options for your configuration suite: (Default does not produce results log)
    • logResults(AxeReportingOptions)

Accessibility context and options can be chained:

assertThat(axeDevtoolsSelenium, isAxeClean()
  .within("#header")
  .within("#footer")
  .excluding(".graphics")
  .accordingTo("wcag2a", "wcag2aa"));

static IsAccessible isAxeClean()

Assert accessibility for web page. Only way of obtaining an IsAxeClean instance.

Returns a new isAxeClean base matcher.

com.deque.html.axedevtools.matchers.IsAuditedForAccessibility extends AxeDevtoolsMatcher

Perform an audit on the accessibility of your page. The audit will log accessibility issues to target/axe-report/accessibility-check.log and create a json output of the results at target/axe-report/accessibility-check.json.

This matcher will never throw an assertion exception. Monitoring audit results for regressions will need to be handled outside of test suite failures / passes when using this matcher.

  • Perform accessibility audit:
    • assertThat(page, isAuditedForAccessibility())
  • Define the context using: (Check the entire document by not using any of these)
    • within(String...)
    • within(Selector...)
    • excluding(String...)
    • excluding(Selector...)
  • Define the options using: (Check all rules defined by axe standards by skipping this step)
    • accordingTo(String...)
    • checkingOnly(String...)
    • checking(String...)
    • skipping(String...)
  • Define the configuration of your audit suite: (Use the default audit configuration location by skipping this step)
    • forConfig(URL)
    • forConfig(String)
  • Define the logging options for your configuration suite: (Default does not produce results log)
    • logResults(AxeReportingOptions)

Accessibility context and options can be chained:

assertThat(axeDevtoolsSelenium, isAuditedForAccessibility()
  .within("#header")
  .within("#footer")
  .excluding(".graphics")
  .accordingTo("wcag2a", "wcag2aa"));

static IsAuditedForAccessibility isAuditedForAccessibility()

Assert web page is audited for accessibility. Only way of obtaining an IsAuditedForAccessibility instance.

Returns a new isAuditedForAccessibility base matcher.

interface com.deque.html.axedevtools.matchers.selectors.Selector

Interface that selectors implement.

com.deque.html.axedevtools.matchers.selectors.ElementSelector implements Selector

ElementSelector(final String cssSelector)

Create a Selector for a CSS selector.

cssSelector: A CSS selector.

com.deque.html.axedevtools.matchers.selectors.IFrameSelector implements Selector

IFrameSelector(final String frameSelector, final String cssSelector)

Create iFrame selector.

frameSelector: CSS Selector representing location of frame on page.

cssSelector: CSS Selector representing web element to perform accessibility testing within the frame.

IFrameSelector(final String frameSelector, final Selector selector)

Create iFrame selector.

frameSelector: CSS Selector representing location of frame on page.

selector: A Selector representing another {@link IFrameSelector}, or an {@link ElementSelector}