Clear text from an input field before typing
How to clear text from an input field before typing: install the Chrome extension, click Build with Browser agent, tell the agent what you want, and follow its prompts. A working bot is built and tested in minutes.
Here is how the automation works. To clear text from an input field, click the field with Click element, delete what is in it with Press key(s), then type the new value with Enter text. Enter text clears a field before typing on its own, so you need this only when a default value is left behind and mixes with the new text.
Build clearing the input field from a description
Describe it and click the button: the agent builds and tests the form filler in your Chrome extension.
- Go to the form page I give you
- Clear the text already in the name field
- Type the new name into that field
You need the URL of a form page with an input field that keeps a default value. In a longer automation, the two clearing steps go directly before the Enter text step that fills the field.
Build clearing the input field step by step
The steps the agent builds, as the Builder shows them: each step by its name, with the fields to set under it. Add them yourself in this order in the step-by-step builder, or open the agent's result there to adjust it.
- 1.0
Go to pageURL: the form page
- 2.0
Click elementSelect: the name field
- 3.0
Press key(s)Key: the right arrow key enough times to pass the end of the value, then Delete on a Mac or Backspace on Windows the same number of times
- 4.0
Enter textSelect text field: the same name fieldText: the new name
Common questions about clearing the input field
Why does Enter text not clear the input field?
Some fields keep their default value. Enter text clears the field before typing unless Append to existing is on, so check that toggle first. If it is off and the old value stays, add the two clearing steps above. When a run fails, hand it to the agent and it repairs the step.
Why does the old value mix with the new text in the input field?
The field kept its default value and the new text was typed after it. Put the Click element and Press key(s) steps directly before the Enter text step, and check the key presses are enough to reach past the end of the longest value the field holds.
How do I add text to an input field without clearing it?
Turn on Append to existing in the Enter text step. The new value is added to whatever is already in the field.
How do I know how many key presses clear the input field?
Record at least as many as the longest value the field holds. Extra presses do nothing once the field is empty, so record a few more than you expect.
Can I clear a field in a form I fill from a Google Sheet?
Yes. The same two steps go inside the loop, directly before the Enter text step that types the row's value into the field.
What other keyboard workarounds can I use in a form?
Use keystrokes as workarounds covers other recorded keys that help when a step does not behave as expected on a page.
Where do I get help?
Get in touch with support, or ask in the axiom.ai community.
Related guides
Keyboard shortcuts as a workaround in browser automation
- Go to the page I give you
- Click inside the box with the scrollbar
- Press the down arrow key to scroll it
Search a website for every term in a Google Sheet and open the result
- Read the search terms from my Google Sheet
- Open the site and search for each term
- Click the first result
- Delete the row once it is done
Send Google Messages to contacts from a Google Sheet
- Read the phone numbers from my Google Sheet
- Open Google Messages and start a chat with each
- Type my message with the person's name and send it
- Delete the row once it is sent