Enter text

axiom.enterText(selectTextField, text) enters text into the first element matching a CSS selector. The same step type as the No-Code Tool's Enter text, called from your code.

Signature


await axiom.enterText(selectTextField, text, delay, appendExisting, customLineBreak, optionalText);
ParameterTypeRequiredDefaultDescription
selectTextFieldstringYesCSS selector for the input.
textstringYesText to enter into the input.
delaynumberNo0Per-keystroke delay in milliseconds. Use a non-zero value (e.g. 50–100) when target sites debounce input or run keystroke-based validation.
appendExistingbooleanNofalseWhen true, appends to the field's current value instead of replacing it.
customLineBreakstring | nullNonullToken in text to translate into a real newline keypress. Use this when the field treats Enter as "submit" but you want literal multi-line input.
optionalTextbooleanNofalseWhen true, the call resolves successfully even if the selector matches zero elements.

Example


await axiom.browserOpen();
await axiom.goto("https://example.com/login");
await axiom.enterText("#email", "user@example.com");
await axiom.enterText("#password", process.env.PW);
await axiom.click("button[type=submit]");

Common patterns


Slow down for picky inputs. Search-as-you-type fields and React-controlled inputs sometimes drop characters when typed instantly. A small per-character delay fixes most cases:

await axiom.enterText("#search", "ergonomic keyboard", 60);

Append rather than replace. By default enterText replaces the field's contents. Set appendExisting to true to add to it:

await axiom.enterText("textarea#notes", "\n\nUpdated " + new Date().toISOString(), 0, true);

Multi-line text without submitting. If the form treats Enter as submit, escape line breaks with a custom token and pass it as customLineBreak:

await axiom.enterText("textarea", "line one<BR>line two<BR>line three", 0, false, "<BR>");

Notes


  • Best results on <input> and <textarea>. Behaviour on contenteditable divs and custom controls (rich-text editors, code editors) varies — test before relying on it.
  • For control keys (Tab, Enter, arrow keys) on their own, use axiom.pressKeys().
  • The element must be focusable. Disabled, hidden, or zero-size inputs throw an error unless optionalText is true.