Squad Bench · Add/Remove Elements

Click to add substitute players to the bench, each with its own Delete button. Counting elements that come and go is the exercise.

Substitutes on, substitutes off. The gaffer wants exactly four on the bench.

Add/Remove Elements is an easy Waits & Dynamics challenge on Fun UI Playground. Click to add substitute players to the bench, each with its own Delete button. Counting elements that come and go is the exercise. It runs entirely in the browser, with no backend. Every interactive element carries a stable id and data-testid prefixed with “add-remove-”, and the techniques it exercises are click to create elements, locate dynamic elements, count elements, delete elements.

At a glance

Category
Waits & Dynamics
Difficulty
easy
Teaches
click to create elements · locate dynamic elements · count elements · delete elements
Backend
None — runs entirely in the browser
Locators
Stable id and data-testid, prefixed add-remove-

Selectors on this page

LocatorWhat it is
#add-remove-add #add-remove-benchAdd: #add-remove-add · each substitute renders as button.added-manually inside #add-remove-bench
#add-remove-countLive count in #add-remove-count — assert it after each add/delete

Frequently asked questions

How do I count elements that are added and removed dynamically?

Click #add-remove-add to append button.added-manually elements inside #add-remove-bench, and assert the live total in #add-remove-count after each add or delete. Counting a locator's matches works too, provided you re-evaluate it rather than reusing a captured list.

How do I delete a specific dynamically added element?

Every substitute deletes itself when clicked, and substitutes are numbered deterministically (Sub 1, Sub 2, …) within a visit — so locate by visible text, click it, then assert both its disappearance and the new #add-remove-count.

More Waits & Dynamics

Updated

Fun UI Playground — all challenges, bug hunts, getting started, glossary, about.