Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make find queries "lazier" #546

Open
jrolfs opened this issue Sep 28, 2022 · 0 comments
Open

Make find queries "lazier" #546

jrolfs opened this issue Sep 28, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@jrolfs
Copy link
Member

jrolfs commented Sep 28, 2022

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...

#501 (comment)

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 returns Promise<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 the Promise<Locator>, like so:

await screen.findByRole('button', { name: 'Apply' }).click();

Could the concept of LocatorPromise providing a .within() method be extended to support calling other Locator methods directly upon the LocatorPromise or would this cause problems?

@jrolfs jrolfs added the enhancement New feature or request label Sep 28, 2022
@jrolfs jrolfs self-assigned this Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant