Open
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
Locator
methods onto thePromise<Locator>
, like so:await screen.findByRole('button', { name: 'Apply' }).click();Could the concept of
LocatorPromise
providing a.within()
method be extended to support calling otherLocator
methods directly upon theLocatorPromise
or would this cause problems?