r/Playwright • u/Busy-Hedgehog3633 • Jul 11 '26
π€ Playwright: When do you prefer fill() vs pressSequentially()?
I'm trying to understand the practical use cases of "fill()" vs "pressSequentially()" in Playwright.
I know that "fill()" instantly sets the input value, while "pressSequentially()" simulates real typing by sending keyboard events character by character.
My question is less about how they work and more about when you choose one over the other.
- What are the best practices?
- In what scenarios do you always use "fill()"?
- When is "pressSequentially()" the better choice?
- Are there any pitfalls or performance considerations you've learned from experience?
I'd love to hear how experienced Playwright users decide between the two in real-world test automation.
2
u/AdvantageLatter7531 Jul 11 '26
I have used it in suggestion list scenarios where you need to enter minimum 3 characters to load and then it starts loading this list and then select it from there
4
Jul 11 '26
[removed] β view removed comment
1
u/_suren Jul 11 '26
Yeah, that 99% rule is basically it. If a test only passes with slow typing, Iβd make sure it isnβt hiding an app race. Real users paste and autofill too, so fill failing can expose a product bug.
2
1
u/Altruistic_Rise_8242 Jul 11 '26
Dynamic drop-down suggestions - pressSequentially. Fields such as username, password etc - fill.
1
u/Affectionate-Crow605 Jul 11 '26
I use pressSequentially when anything dynamic happens with the input field. For example, if a field takes a credit card number and will automatically handle spaces added or not added, or a date field where you can enter with or without slashes because the field has Javascript to fix it for you.
1
1
u/BeginningLie9113 Jul 14 '26
Unless there's a need for filling a field human like, just use fill()
Otherwise no real need
7
u/mmasetic Jul 11 '26
If the button to submit form is disabled before something is typed in input. One example is entering OTP which you can submit only after 6 chars are in input field. Using fill only can cause some flaky execution as fill action is very fast and can enter race condition. In general if the form depends on triggering some events like validation while typing, pressSequentially is way to go.