Referencia de la API de Python de axe-devtools-api

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard
Not for use with personal data

Proporciona una API con la que inyectar y configurar axe.

Uso

Inicialice con un adaptador de navegador (como un AxeDriver adaptador de axe-devtools-selenium) y, opcionalmente, un informe Objeto de configuración o una cadena de código fuente de axe-core.

class Axe():
    def __init__(self, page, report_configuration = None, axe_source = None):
        ...

Se proporcionan los siguientes métodos:

def analyze(self):
    """Run axe on the page

    Returns:
        The results from running axe-core on the page
    Examples:
        >>> report = Axe(page).analyze()
    """
def including(self, *selector):
    """Specify part of the page to run axe on.

    Args:
        selector: List of CSS selectors for elements

    Returns:
        This object for chaining

    Examples:
        >>> report = Axe(page).including(".sidebar-frame", ".some-class").analyze()
    """
def excluding(self, *selector):
    """Specify part of the page to exclude when runing axe.

    Args:
        selector: List of CSS selectors for elements

    Returns:
        This object for chaining

    Examples:
        >>> report = Axe(page).excluding(".iframe1",".third-party-ad").analyze()
    """
def with_rules(self, *rules):
    """Specify rules (by id) to use when running axe.

    Only the specified rules are used.

    List of rules available here: https://dequeuniversity.com/rules/axe/4.1

    Args:
        rules: List of ids of rules

    Returns:
        This object for chaining

    Raises:
        RuntimeError: If you try to call both `with_rules` and `with_tags` on the same object

    Examples:
        >>> report = Axe(page).with_rules("document-title", "label").analyze()
    """
def with_tags(self, *tags):
    """Specify rules (by tag) to use when running axe.

    Only specified rules are used.

    List of tags here: https://www.deque.com/axe/core-documentation/api-documentation/#axe-core-tags

    Args:
        tags: List of tags of rules

    Returns:
        This object for chaining

    Raises:
        RuntimeError: If you try to call both `with_rules` and `with_tags` on the same object

    Examples:
        >>> report = Axe(page).with_tags("best-practice", "wcag2a").analyze()
    """
def disabling_rules(self, *rules):
    """Disable some rules when running axe.

    List of rules available here: https://dequeuniversity.com/rules/axe/4.1

    Args:
        rules: List of ids of rules

    Returns:
        This object for chaining

    Examples:
        >>> report = Axe(page).disabling_rules("html-has-lang", "label")
    """
def run_options(self, options):
    """Specify runOptions to pass to axe when calling axe.run

    Documentation can be found here: https://www.deque.com/axe/core-documentation/api-documentation/#options-parameter

    Args:
        options: Object to pass

    Returns:
        This object for chaining

    Examples:
        >>> options = { "iframes": False }
        >>> report = Axe(page).run_options(options).analyze()
    """
def configure(self, spec):
    """Configure axe. Done via axe.configure.

    Args:
        spec: Spec object to pass

    Returns:
        This object for chaining

    Examples:
        >>> import spec
        >>> report = Axe(page).configure(spec).analyze()
    """
def without_iframe_sandboxes(self):
    """Remove the `sandbox` attribute from `iframe`s so that axe runs in them.

    Returns:
        This for chaining

    Examples:
        >>> report = Axe(page).without_iframe_sandboxes().analyze()
    """
def with_config_file(self, config_path):
    """Set where to find a config file.

    Default path is `config/axe-ruleset.json` or `$AXE_RULESET_PATH`

    Args:
        config_path: Path to config file

    Returns:
        This object for chaining

    Examples:
        >>> report = Axe(page).with_config_file("path/to/file.json").analyze()
    """
def with_ruleset(self, ruleset_id, enable_best_practices = False):
    """Use a specific ruleset

    Available rulesets: wcag2, wcag2.1, wcag2.2, wcag2aaa, wcag2.1aaa, wcag2.2aaa, 508, en301549, ttv5

    Args:
        ruleset_id: id of the ruleset to use
        enable_best_practices: Whether or not to turn on rules tagged `best-practice`. Default off

    Returns:
        This object for chaining

    Examples:
        >>> report = Axe(page).with_ruleset("508").analyze()
    """

Servicio de uso

Obtenga información sobre las tendencias de uso de axe DevTools dentro de su organización

De forma predeterminada, el servicio de utilización está deshabilitado y la URL predeterminada es https://usage.deque.com.

Variables de entorno

Este método permite a los usuarios cambiar valores específicos del servicio de utilización a través de variables de entorno.

Variable ambiental Tipo
AXE_IS_LOGGED_IN Booleano
AXE_KEYCLOAK_ID Cadena
AXE_USER_ID Cadena
AXE_SESSION_ID Cadena
AXE_USER_STATUS Cadena
AXE_USER_JOB_ROLE Cadena
AXE_DISTINCT_ID Cadena
AXE_IS_DEV_INSTANCE Booleano
AXE_ORGANIZACIÓN Cadena
APLICACIÓN AXE Cadena
AXE_METRICS_URL Cadena
AXE_TRACK_USAGE Booleano
def enable_tracking(self, state):
    """Opt in or out of sending data to usage service.

    Args:
        state: whether tracking is enabled

    Returns:
        This object for chaining

    Examples:
        >>> report = Axe(page).enable_tracking(True).analyze()
    """
    self.analytics.enable_tracking(state)
    return self
def set_tracking_url(self, url):
    """Set where usage metrics data are sent.

    Args:
        url: url where it will be sent

    Returns:
        This object for chaining

    Examples:
        >>> report = Axe(page).set_tracking_url("https://usage.deque.com").analyze()
    """
    serlf.analytics.url(url)
    return self
def set_distinct_id(self, id):
    """Set distinct id used when sending usage metrics.

    Args:
        id: distinct id to send

    Returns:
        This object for chaining

    Examples:
        >>> report = Axe(page).set_distinct_id("SOMEUUID").analyze()
    """
    self.analytics.distinct_id(id)
    return self

Ejemplo

El siguiente es un ejemplo de archivo robot.

*** Settings ***
Library  axe_devtools_robot.AxeRobot
Suite Setup  set log level  DEBUG


*** Test Cases ***
Analyzes
  Open Browser  http://localhost:8000/example-page.html  Chrome
  Analyze
Audits
  Open Browser  http://localhost:8000/example-page.html  Chrome
  Audit For Accessibility

Uses Within
  Open Browser  http://localhost:8000/example-page.html  Chrome
  Within  body
  Analyze
Close browsers
  Close All Browsers