In this episode, we dive into the world of more complex selectors in our end-to-end tests. Instead of just clicking buttons or using simple selectors, we learn how to use CSS selectors to target really specific elements on the page—for example, deleting just the second task in a list.
We walk through a practical example: we create three tasks and show how to delete only the middle one by crafting a selector that picks it out specifically. The video demonstrates how to use your browser's console (with document.querySelector
) to experiment and confirm you're selecting the right item before bringing that selector into your tests. This is super helpful, especially when working with lists or repeated elements, so you can always go for the exact thing you want and avoid any accidental clicks.
You'll also get to see common mistakes (like remembering that lists are zero-indexed!) and how to debug them. By the end, you’ll know how to build selectors for both the parent item and, say, its delete button, and confidently add these selectors to your tests for precise targeting.