question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Add locator.clear() for input fields

See original GitHub issue

I would like to request a locator.clear() functionality (similar to the one found in other frameworks) to empty the content of input fields (shouldn’t be limited to input and textarea elements though since elements don’t always follow these conventions).

Unfortunately, the workaround of using locator.fill('') doesn’t work reliably, it doesn’t change the content of some input fields at all.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:13
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mxschmittcommented, May 11, 2022

However, this feature request wasn’t so much about my specific issue but rather about improving PW in general by adding a locator.clear() function so people don’t need to do locator.fill(‘’) which is less elegant. 😃

I agree there, fill(‘’) is not very idiomatic!

0reactions
akwasincommented, Oct 7, 2022

Im up for this one as well

await page.fill(‘[data-testid=“input-name”] input’, ‘Slim Shady’); await page.fill(‘[data-testid=“input-name”] input’, ‘’); await page.fill(‘[data-testid=“input-name”] input’, ‘Dr Dre’);

This doesnt sit right.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to clear() input fields in web? - Katalon Community
1.- Add a new “Web UI Keyword” · 2.- Choose the keyword “Send Keys” · 3.- Doubleclick on the object column and find...
Read more >
Clear input fields on form submit - javascript - Stack Overflow
I'd like to simply have the two input fields in my page to clear when I click submit (&& enter - unless its...
Read more >
Handling different types of inputs | Playwright with Typescript ...
Handling different types of inputs :In this video, we are going to learn how to handle different types of input fields.
Read more >
How To Clear Input Field on Focus - W3Schools
Learn how to clear an input field on focus. Click on the input field to clear it: Clear Input Field on Focus. Example....
Read more >
Add, copy, or remove a text box in Word - Microsoft Support
Select a location and press Ctrl+V to paste the text box. Delete a text box. Select the border of the text box that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found