Skip to main content

type

codebolt.browser.type(elementid: string, text: string): Promise<TypeResponse>
Types text into a specified element on the page.

Parameters

NameTypeDescription
elementidstringThe ID of the element to type into.
textstringThe text to type.

Example

// Navigate to a page with input forms
await codebolt.browser.goToPage("https://example.com/form");
await new Promise(resolve => setTimeout(resolve, 2000));

// Type text into various input fields
const typeResult = await codebolt.browser.type("username", "testuser");
console.log('✅ Typed username:', typeResult);

// Type email into email field
await codebolt.browser.type("email", "[email protected]");

// Type password into password field
await codebolt.browser.type("password", "securepassword123");

// Type into a textarea
await codebolt.browser.type("message", "This is a test message");

Important Note

The type() function requires the target input element to have a specific ID and be present on the page. Interactive tests like type() require specific element IDs which may not be available on all pages. Ensure that the target input element exists and is editable before calling this function.

Explanation

The codebolt.browser.type(elementid, text) function simulates typing text into a specified input element on the current web page. The function takes two parameters: an element ID (string) and the text to type (string). It returns a promise that resolves when the typing action is complete. This function is essential for automating form filling, data entry, search queries, and any scenario where text input is required. It works with various input types including text fields, email fields, password fields, and textareas.