---
title: Accessibility Testing with Selenium and TestingBot
description: Run Automated Accessibility tests against websites with Axe and the TestingBot
  browser grid. Improve the accessibility of your website with TestingBot's comprehensive
  testing tools.
source_url:
  html: https://testingbot.com/support/accessibility/web/selenium
  md: https://testingbot.com/support/accessibility/web/selenium/index.md
---
# Accessibility testing

Automated Accessibility Testing (A11y) allows you to test if your website follows the Web Content Accessibility Guidelines (WCAG) rules and other guidelines, to ensure your website is accessible to all types of users.

## Example

The following example will start a browser in the TestingBot browser grid, navigate to a website and call the custom `tb:accessibility` command to fetch the accessibility results.

We will then retrieve the results from the accessibility test from inside our automated test. The results will be saved in a JSON file for inspection.

[Java](https://testingbot.com#)[NodeJS](https://testingbot.com#)[C#](https://testingbot.com#)[Python](https://testingbot.com#)[Ruby](https://testingbot.com#)[PHP](https://testingbot.com#)

    #!/usr/bin/env ruby
    
    require 'rubygems'
    require 'selenium-webdriver'
    
    options = Selenium::WebDriver::Options.chrome
    options.browser_version = 'latest'
    options.platform_name = 'WIN11'
    options.add_option('tb:options', { 'name' => 'Accessibility Test' })
    
    driver = Selenium::WebDriver.for(
    	:remote,
    	url: "https://api_key:api_secret@hub.testingbot.com/wd/hub",
    	capabilities: options
    )
    driver.navigate.to "https://testingbot.com"
    result = driver.execute_script('tb:accessibility')
    require 'json'
    File.write("path/to/report.json", JSON.generate(result))
    driver.quit

    import com.fasterxml.jackson.databind.ObjectMapper;
    import org.openqa.selenium.*;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.RemoteWebDriver;
    
    import java.io.FileWriter;
    import java.net.URL;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.util.HashMap;
    import java.util.Map;
    
    public class AccessibilityTest {
    
        public static final String KEY = "api_key";
        public static final String SECRET = "api_secret";
        public static final String REMOTE_URL = "https://" + KEY + ":" + SECRET + "@hub.testingbot.com/wd/hub";
    
        public static void main(String[] args) {
            WebDriver driver = null;
    
            try {
                ChromeOptions options = new ChromeOptions();
                options.setBrowserVersion("latest");
                options.setPlatformName("WIN11");
    
                Map tbOptions = new HashMap<>();
                tbOptions.put("name", "Accessibility Test");
                options.setCapability("tb:options", tbOptions);
    
                driver = new RemoteWebDriver(new URL(REMOTE_URL), options);
                driver.get("https://testingbot.com");
    
                JavascriptExecutor js = (JavascriptExecutor) driver;
                Object result = js.executeScript("tb:accessibility");
    
                Path outputPath = Files.createTempFile("accessibility-report", ".json");
                try (FileWriter writer = new FileWriter(outputPath.toFile())) {
                    writer.write(new ObjectMapper().writeValueAsString(result));
                    System.out.println("Accessibility report saved to: " + outputPath.toAbsolutePath());
                }
    
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (driver != null) {
                    driver.quit();
                }
            }
        }
    }

    <?php
    
        require_once('vendor/autoload.php');
        use Facebook\WebDriver\Remote\RemoteWebDriver;
        use Facebook\WebDriver\Remote\DesiredCapabilities;
    
        $capabilities = DesiredCapabilities::chrome();
        $capabilities->setCapability('platformName', 'WIN11');
        $capabilities->setCapability('browserVersion', 'latest');
        $capabilities->setCapability('tb:options', ['name' => 'Accessibility Test']);
    
        $web_driver = RemoteWebDriver::create(
            "https://api_key:api_secret@hub.testingbot.com/wd/hub",
            $capabilities, 120000
        );
        $web_driver->get("https://testingbot.com");
        $result = $web_driver->executeScript('tb:accessibility');
        file_put_contents("path/to/report.json", json_encode($result, JSON_PRETTY_PRINT));
        $web_driver->quit();
    ?>

    import json
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    options.browser_version = 'latest'
    options.platform_name = 'WIN11'
    options.set_capability('tb:options', {'name': 'Accessibility Test'})
    
    driver = webdriver.Remote(
        command_executor='https://api_key:api_secret@hub.testingbot.com/wd/hub',
        options=options
    )
    driver.get("https://testingbot.com")
    result = driver.execute_script('tb:accessibility')
    with open("path/to/report.json", "w") as file:
        json.dump(result, file, indent=2)
    driver.quit()

    const { Builder } = require('selenium-webdriver');
    const fs = require('fs/promises');
    
    const TESTINGBOT_KEY = 'api_key';
    const TESTINGBOT_SECRET = 'api_secret';
    
    const capabilities = {
      browserName: 'chrome',
      browserVersion: 'latest',
      platformName: 'WIN11',
      'tb:options': {
        name: 'Accessibility Test'
      }
    };
    
    async function runAccessibilityTest() {
      let driver;
    
      try {
        driver = await new Builder()
          .usingServer(`https://${TESTINGBOT_KEY}:${TESTINGBOT_SECRET}@hub.testingbot.com/wd/hub`)
          .withCapabilities(capabilities)
          .build();
    
        await driver.get('https://testingbot.com');
        const result = await driver.executeScript('tb:accessibility');
    
        const filePath = 'accessibility-report.json';
        await fs.writeFile(filePath, JSON.stringify(result, null, 2));
        console.log(`Accessibility report saved to ${filePath}`);
      } catch (error) {
        console.error('Test failed:', error);
      } finally {
        if (driver) {
          await driver.quit();
        }
      }
    }
    
    runAccessibilityTest();

    using System;
    using System.Collections.Generic;
    using System.IO;
    using Newtonsoft.Json;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Remote;
    
    namespace SeleniumTest {
      class Program {
        static readonly string report = @"path/to/report.json";
    
        static void Main(string[] args) {
          var options = new ChromeOptions();
          options.BrowserVersion = "latest";
          options.PlatformName = "WIN11";
          options.AddAdditionalOption("tb:options", new Dictionary<string, object> {
            { "name", "Accessibility Test" }
          });
    
          var driver = new RemoteWebDriver(
            new Uri("https://api_key:api_secret@hub.testingbot.com/wd/hub"),
            options
          );
          driver.Navigate().GoToUrl("https://testingbot.com");
    
          var result = driver.ExecuteScript("tb:accessibility");
          File.WriteAllText(report, JsonConvert.SerializeObject(result, Formatting.Indented));
    
          driver.Quit();
        }
      }
    }

You could write `assertions` to pass/fail your test depending on the accessibility issues found.

## Results

After running the example test, you will find a `report.json` file with the results of the accessibility test.

The file will contain the following structure:

    {
      "testEngine": { },
      "testRunner": { },
      "testEnvironment": { },
      "toolOptions": { },
      "url": "https://testingbot.com",
      "timestamp": "2026-05-13T12:00:00.000Z",
      "passes": [],
      "violations": [],
      "incomplete": [],
      "inapplicable": []
    }

- `violations` includes the rules that were violated and need to be fixed. 
- `passes` the rules that have passed successfully. 
- `incomplete` incomplete results, either due to an error or aborted test 
- `inapplicable` no matching content was found for these rules. 

An overview of all accessibility rules that will be checked can be found on [A11Y rules overview](https://testingbot.com/support/accessibility/web/rules).

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
