Accessibility, Visual and Performance Checks in Selenium

Selenium 14 min min read Updated: Nov 16, 2026 Advanced
Accessibility, Visual and Performance Checks in Selenium
Advanced Topic 2 of 3

1. Accessibility Testing

Accessibility means people with disabilities (screen readers, keyboard only, low vision) can use your site. Automated tools find roughly a third of the problems very quickly, such as missing alt text, low contrast and missing form labels.

bash pip install axe-selenium-pytho
python from axe_selenium_python import Axe def test_home_page_has_no_critical_accessibility_issues(driver): driver.get("https://the-internet.herokuapp.com/") axe = Axe(driver) axe.inject() # adds the axe-core script to the page results = axe.run() serious = [v for v in results["violations"] if v["impact"] in ("critical", "serious")] for v in serious: print(v["id"], "-", v["help"], "-", len(v["nodes"]), "elements") assert not serious, f"{len(serious)} serious accessibility problems found"
Common findingFix
Images without altAdd a description
Form field without labelAdd <label for> or aria-label
Low colour contrastUse darker text or lighter background
Missing page language<html lang="en">
Buttons without textAdd visible text or aria-label
Not a replacement for manual checks: Automatic scans cannot judge whether the page makes sense with a screen reader. Add a manual keyboard-only test (Tab, Enter, Escape) in your regular testing.

Keyboard Navigation Test

python from selenium.webdriver.common.keys import Keys def test_can_reach_login_button_with_tab(driver): driver.get("https://www.saucedemo.com") body = driver.find_element(By.TAG_NAME, "body") for _ in range(3): body.send_keys(Keys.TAB) assert driver.switch_to.active_element.get_attribute("id") == "login-button"

2. Visual Regression Testing

Visual tests compare a new screenshot with an approved baseline. They catch layout problems that normal assertions miss (overlapping text, broken CSS).

bash pip install pillow
python from pathlib import Path from PIL import Image, ImageChops BASELINE = Path("visual/baseline") ACTUAL = Path("visual/actual") def assert_matches_baseline(driver, name, tolerance=0): ACTUAL.mkdir(parents=True, exist_ok=True) BASELINE.mkdir(parents=True, exist_ok=True) actual_path = ACTUAL / f"{name}.png" driver.save_screenshot(str(actual_path)) baseline_path = BASELINE / f"{name}.png" if not baseline_path.exists(): actual_path.replace(baseline_path) # first run creates the baseline return a = Image.open(actual_path).convert("RGB") b = Image.open(baseline_path).convert("RGB") assert a.size == b.size, f"Image size changed: {a.size} vs {b.size}" diff = ImageChops.difference(a, b) bbox = diff.getbbox() if bbox is not None: changed = sum(1 for px in diff.getdata() if px != (0, 0, 0)) assert changed <= tolerance, f"{changed} pixels differ. See {actual_path}"
Make screenshots stable: Fix the window size, hide dates, ads and animations (inject CSS), wait for fonts and images, and use the same browser and OS as the baseline. Tools such as Applitools, Percy and BackstopJS handle this for you.

3. Performance Checks

python def test_home_page_loads_fast(driver): driver.get("https://www.selenium.dev") nav = driver.execute_script("return performance.getEntriesByType('navigation')[0].toJSON()") dom_ready = nav["domContentLoadedEventEnd"] load_time = nav["loadEventEnd"] print(f"DOM ready: {dom_ready:.0f} ms, full load: {load_time:.0f} ms") assert load_time < 5000, f"Page took {load_time:.0f} ms to load"

For deeper analysis run Lighthouse (in Chrome DevTools or npx lighthouse <url>) in your CI pipeline and fail the build when the score falls under a limit.

Performance of the test run is not load testing: Selenium measures what one user sees. To simulate thousands of users use tools such as JMeter, k6 or Locust.

Conclusion

Add small automatic checks to your suite: axe for accessibility, screenshot comparison for layout and navigation timing for speed. They find problems that normal functional tests miss.

Quick Summary: axe = accessibility, image diff = visual, performance.timing = speed.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators