axe-devtools-api Python API-Referenz

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

Bietet eine API zum Einfügen und Konfigurieren von Axe.

Verwendung

Initialisieren Sie mit einem Browser-Adapter (wie einem Adapter AxeDriver von axe-devtools-selenium) und optional einem Bericht Konfigurationsobjekt oder eine Zeichenfolge mit Axe-Core-Quellcode.

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

Die folgenden Methoden stehen zur Verfügung:

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

Usage Service

Erhalten Sie Einblick in die Nutzungstrends von axe DevTools in Ihrem Unternehmen

Standardmäßig ist der Nutzungsdienst deaktiviert und die Standard-URL lautet https://usage.deque.com.

Umgebungsvariablen

Mit dieser Methode können Benutzer bestimmte Werte des Nutzungsdienstes über Umgebungsvariablen ändern.

Umgebungsvariable Art
AXE_IS_LOGGED_IN Boolescher Wert
AXE_KEYCLOAK_ID String
AXE_USER_ID String
AXE_SESSION_ID String
AXE_BENUTZER_STATUS String
AXE_BENUTZER_JOB_ROLLE String
AXE_DISTINCT_ID String
AXE_IS_DEV_INSTANCE Boolescher Wert
AXE_ORGANISATION String
AXE_ANWENDUNG String
AXE_METRICS_URL String
AXE_NUTZUNGSVERFOLGUNG Boolescher Wert
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

Beispiel

Nachfolgend sehen Sie ein Beispiel für eine Roboterdatei.

*** 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