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

[Feature] Fill input field based on label text #3466

Closed
torkjels opened this issue Aug 14, 2020 · 1 comment · Fixed by #4342
Closed

[Feature] Fill input field based on label text #3466

torkjels opened this issue Aug 14, 2020 · 1 comment · Fixed by #4342
Assignees

Comments

@torkjels
Copy link

When an input field is properly connected to a label it would be nice to be able to fill the input field based on the label text using await page.fill('text=Name', 'John Doe');.

It's often possible to fill the input field based on a CSS selector like id or name, but making it possible to fill by label text would make it more straight-forward to both read and write the test. Especially if you write tests for screens you did not make yourself.

Examples of cases where it should work:

<label for="input1">Name</label>
<input id="input1" value="">
<label>Name <input value=""></label>

@Snooz82
Copy link
Contributor

Snooz82 commented Aug 17, 2020

i think in general label= could be a nice selector strategy.
I would feel comfortable to mix it with general Text selector, because then it would be possible anymore to select the tag itself with the "Text" selector.

i would also not limit it to fields!
Labels can be used on:

<input>
<meter>
<progress>
<select>
<textarea>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants