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.

[Question] How to clear all the data in the text field?

See original GitHub issue

I have been trying to clear all the data in the text field. await this.page.keyboard.press('Backspace'); works for me but it deletes only one character. Is there any other way to clear the whole field? OR Do i need to run this backspace in a loop to clear characters one by one?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:24 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
hex0ctercommented, Sep 21, 2022

Given that so many people are still having this issue, maybe this ticket should be re-opened? @pavelfeldman

1reaction
gauravgandhi1315commented, Dec 7, 2022

@rovmak Better way to do is

  async clearTextField(locator) {
    // click on the text field
    await this.clickOnElement(locator);
    await this.page.keyboard.press("Meta+A");
    await this.page.keyboard.press('Backspace');
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML | Clearing the input field - GeeksforGeeks
To clear the entire input field without having to delete the whole thing manually Or what if there is already a pre-suggested input...
Read more >
How do I clear the previous text field value after submitting the ...
It will clear all the fields. let inputs = document.querySelectorAll("input"); inputs.forEach((input) => (input.value = ""));.
Read more >
Clear all TextBox after data save - MSDN - Microsoft
You can find the control from form in a recuisive way and clear the textboxs. private void getAllCtl(ControlCollection ctls) { foreach (Control c...
Read more >
Clear the text inside the text box fields using Selenium ...
Clear the text inside the text box fields using Selenium WebDriver (Selenium Interview Question #18) · Chapters. View all · Chapters · Description....
Read more >
Clearing the values in text fields - SAP Community
After logging in Press Alt+F12 -> Options -> Local Data - > Clear History. This will clear the cache in your SAP Work...
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