Riferimento API Python 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

Fornisce un'API con cui iniettare e configurare axe.

Uso

Inizializza con un adattatore del browser (ad esempio un AxeDriver da axe-devtools-selenium) e, facoltativamente, un report Oggetto di configurazione o una stringa di codice sorgente axe-core.

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

Sono previsti i seguenti metodi:

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()
    """

Servizio di utilizzo

Ottieni informazioni sulle tendenze di utilizzo di axe DevTools all'interno della tua organizzazione

Per impostazione predefinita, il servizio di utilizzo è disabilitato e l'URL predefinito è https://usage.deque.com.

Variabili ambientali

Questo metodo consente agli utenti di modificare valori specifici del servizio di utilizzo tramite variabili di ambiente

Variabile d'ambiente Tipo
AXE_IS_LOGGED_IN Booleano
AXE_KEYCLOAK_ID String
AXE_UTENTE_ID String
AXE_SESSIONE_ID String
STATO_UTENTE_AXE String
RUOLO_PROFESSIONE_UTENTE_AXE String
AXE_DISTINTO_ID String
ISTANZA_DEV_IS_AXE Booleano
AXE_ORGANIZZAZIONE String
AXE_APPLICAZIONE String
AXE_METRICS_URL String
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

Esempio

Di seguito è riportato un esempio di file 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