# Test alert, confirm and prompt, and the browser's permission prompts

> These boxes belong to the browser, not the page, and they stop everything until answered. One plain-language test accepts, cancels, types an answer, allows and blocks.

By Jason Nguyen, Founder, Testsy. Published 2026-11-20. https://testsy.dev/blog/test-browser-dialogs-and-permission-prompts/

## The boxes your page does not draw

Some of what a user sees on your site is not your site. The browser draws it:

- **Alert, confirm and prompt.** The plain grey boxes: "Are you sure you want to delete this?" with OK and Cancel. They block the page until someone answers.
- **Permission prompts.** "This site wants to know your location." "This site wants to show notifications." Allow or Block.

A test script cannot click these the way it clicks a button, because they are not in the page. Each tool has a special mechanism for them, set up before the box appears, and a test that forgets it hangs until it times out. Permission prompts are usually not answered at all: the script starts the browser with the permission already granted, so the path where a user clicks **Block** is never run.

That path matters. People block notification prompts all the time, and the page has to carry on without them.

## The test

Written as plain text and run in Chrome on a desktop-sized screen:

```text
Open Dialogs. Open the browser alert and accept it, open the browser
confirm and cancel it, then open the browser prompt and answer Sydney.
Verify Alert: shown · Confirm: cancel · Prompt: Sydney.
Go back to Home and open Permissions. Request Location and allow it,
then request Notifications and block them.
Verify Location: granted and Notifications: denied.
```

The site is Web Lab, our practice site. Its Dialogs page opens each kind of browser box and records the answer. Its Permissions page asks the browser for each permission and shows what came back.

## What happened

The picture at the top of this page shows two screens from the run: the Dialogs page reading "Alert: shown · Confirm: cancel · Prompt: Sydney", and the Permissions page with "Location: granted" and "Notifications: denied".

Three boxes, three different answers, in the order the test gave them:

1. The alert was accepted. The page read "Alert: shown".
2. The confirm was cancelled. "Confirm: cancel".
3. The prompt was answered with the word Sydney. "Prompt: Sydney".

Then the permissions. The page asked for the location and the tester allowed it: "Location: granted". The page asked to send notifications and the tester blocked them: "Notifications: denied".

![The result: all 7 checks passed in 45 seconds.](https://testsy.dev/blog/img/web-dialogs-result.webp)

Each box is its own check, and each was decided on what the page showed after the answer.

![The checks. Accept, cancel, an answer typed in, allow, block.](https://testsy.dev/blog/img/web-dialogs-checks.webp)

[Recording: The review video of the run, 43 seconds.](https://testsy.dev/blog/video/web-dialogs.mp4)

Open [the run](https://app.testsy.dev/share/qvm2tEirgWM8SqZtUr96SFwJ5bAoLbkW) to step through it. The link is read-only and stays live until 18 February 2027.

## Write it for your app

The useful tests are the ones where the answer is no:

```text
Open the store finder. When the browser asks for the location,
block it. Check that the page offers a postcode field instead
and that searching for 2000 lists stores in Sydney.
```

```text
Sign in with the stored account "member" and open Projects.
Click Delete on the project "Demo" and cancel the confirmation.
Check that "Demo" is still in the list.
Click Delete again, accept, and check that it is gone.
```

Things to check:

- **Cancel means cancel.** A confirm that deletes on Cancel is rare and catastrophic. One test covers it for good.
- **Block is handled.** After a blocked permission, the feature should explain itself or fall back, not spin.
- **Leaving with unsaved changes.** Edit a form, try to leave, and check the "Leave site?" warning appears and that staying keeps the edits.

The same subject on phones, where the prompts are different again: [Test what your app does when the user says no to a permission](https://testsy.dev/blog/test-permission-prompts-in-a-mobile-app/).

## Run it

Paste your site's address into **New test**, say how each box should be answered, and run it. [Write a test](https://testsy.dev/docs/write-a-test/) covers wording steps and checks.

This post is one of a series: [The hardest parts of web testing, each one run for real](https://testsy.dev/blog/the-hardest-parts-of-web-testing/).
