Skip to content

Modal Handling in Accessibility Tests ​

This document explains how our accessibility testing tool handles modals after they become active.

How It Works ​

Step 1: Open Modal Detection ​

First, the tool looks for any visible modal that may have opened during the test.

Step 1: Three-Stage Closing Process ​

The tool uses a 3-step approach to close any open menus.

Strategy 1: Escape Key ​

First, it attempts to use ESC — the standard key for closing menus and modals. This simulates user-like closing behavior.

Strategy 2: Click Outside ​

The tool clicks on an empty area of the page, which is how most non-persistent modals (with a key to force closure) behave when a user clicks outside the area they occupy.

After simulating the close, it is verified that the number of modals or popups has decreased by at least one compared to the count prior to closing.

Step 2: Focus Restoration ​

After successfully closing a modal, the tool attempts to return keyboard focus to the original element being tested. This ensures that keyboard navigation can continue naturally.