Référence de l'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

Fournit une API avec laquelle injecter et configurer axe.

Usage

Initialiser avec un adaptateur de navigateur (tel qu'un AxeDriver terme manquant de axe-devtools-selenium) et éventuellement un rapport Objet de configuration ou une chaîne de code source axe-core.

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

Les méthodes suivantes sont fournies :

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

Service d'utilisation

Approfondissez votre compréhension des tendances d'utilisation d'axe DevTools au sein de votre organisation

Par défaut, le service d'utilisation est désactivé et l'URL par défaut est https://usage.deque.com.

Variables d'environnement

Cette méthode permet aux utilisateurs de modifier des valeurs spécifiques du service d'utilisation via des variables d'environnement

Variable d'environnement Type
AXE_IS_LOGGED_IN Booléen
AXE_KEYCLOAK_ID Chaîne
AXE_USER_ID Chaîne
AXE_SESSION_ID Chaîne
AXE_STATUT_UTILISATEUR Chaîne
AXE_RÔLE_PROFESSIONNEL_UTILISATEUR Chaîne
AXE_DISTINCT_ID Chaîne
AXE_IS_DEV_INSTANCE Booléen
AXE_ORGANISATION Chaîne
AXE_APPLICATION Chaîne
AXE_METRICS_URL Chaîne
AXE_TRACK_USAGE Booléen
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

Exemple

Ce qui suit est un exemple de fichier 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