This repository was archived by the owner on Aug 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Make find queries "lazier"Β #546
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Following up on the comment below, we'd like to make LocatorPromise (augmented Promise<Locator>) act as much like a locator as possible, within reason...
I've changed some of my code to use
.findByRole(...)recently and something I've noticed which is quite annoying is that it's quite jarring that it returnsPromise<Locator>.In practice, you sometimes end up writing code like this:
await screen.findByRole('button', { name: 'Apply' }); await screen.getByRole('button', { name: 'Apply' }).click(); // -- or -- const applyButton = await screen.findByRole('button', { name: 'Apply' }); await applyButton.click();But wishing that you could continue to chain
Locatormethods onto thePromise<Locator>, like so:await screen.findByRole('button', { name: 'Apply' }).click();Could the concept of
LocatorPromiseproviding a.within()method be extended to support calling otherLocatormethods directly upon theLocatorPromiseor would this cause problems?
sebinsuasebinsua
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request