In this episode, we dig into how to work inside specific parts of a page when writing browser tests. Instead of just looking everywhere on the page for some text or button, sometimes you want to check that something appears in a particular section—like making sure "Tasks" shows up in the header, not just anywhere.
You'll see why simply looking for text globally can give us false positives (like if "Tasks" accidentally appears elsewhere). To fix this, we use "scoping selectors," which basically means telling our tests to look or interact only within a certain element (like the header). You'll learn how to add scoped selectors in your code with Dusk selectors, use assertSeeIn
, and how these differ from just assertSee
.
Then, we'll level up with the with
method, which lets you do more than just check for text. You'll see how you can perform multiple actions, like clicking a link, but only inside a certain element. This is especially handy if you have duplicate buttons or links (like multiple "Dashboard" links) and only want to interact with the one in a specific spot.
By the end of this episode, you'll know how to look for content or interact with elements precisely where you mean to—making your browser tests a lot more accurate and reliable!