-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
how to clear input field value before typing/inserting? #810
Comments
I think this is the desired behaviour. Following the philosophy of that, maybe you should try to insert backspace characters. |
@marcelfalliere OK you're right, what works for me is to do:
however it could be handy to have some API way to do that, either some boolean flag for replace, or some clear method. |
In addition to sending backspace characters as @marcelfalliere said, you can send empty or falsey values to I do have a question:
Meaning that the values are there between runs to the same site? |
correct |
@rosshinkley I'm passing either empty or falsy values for text and none of these seems to clear the input value? |
The method provided by @simov doesn't work for me... I have to resort to using
To clear a text box... seems like |
I did try using:
to emulate Ctrl+A and backspace to empty the field, but this doesn't work on Macs (as Cmd+A is handled by the OS - see puppeteer/puppeteer#1313 ) - however,
does seem to work. |
Why not simply:
Select everything by clicking 3 times and then just start typing, it will replace the selected text. |
This is what I ended up doing: a combination of @mikrstic and @MichaelMartinez
Another approach that also worked for me is:
|
Triple-click seems to only select current para, so that solution fails with a multi-para text input. @tuancaraballo Backspace solution works for me. |
What's the difference when doing this:
|
Keep in mind that Setting the value directly by evaluating js seems to be a good solution too. In my case I'm just trying to be a purist about only simulating user behavior, so the triple click was an improvement in that sense. Edit: I had some issues with the click method when there was an overlay on top of the input. This is working really well for me:
|
how can i clear multiple values from input box using playwright? |
I'm in a situation, that on script re-run are previously inserted input fields prefilled with old values.
So calling:
or
makes the value to be appended only.
Any chance to overwrite?
Currently I'm workarounding it with:
The text was updated successfully, but these errors were encountered: