Testim Documentation

Welcome to the Testim documentation. You'll find comprehensive guides to help you get started quickly, example code snippets, and tips for being more productive. You will also find details about advanced features that allow you to customize Testim to fit your environment or special testing conditions. Don't worry, we'll support you if you get stuck. Let's jump right in!

Guides    Changelog

type(selector, textValue)

This method is used to set an element's text content. If the element already has text content it overrides it.

  • selector {string | TDKStepLocator} a CSS selector or smart locator for the element
  • textValue {string} the value we want to type into the control
  • returns: Promise that fulfills when the action is complete.

For example:

// ✅ type an email in an email type input
await type('input[type=email]', 'benji@testim.io');
// ✅ set an element's text in a smart locator
await type(l('username'), 'benji');
// ✅ type into a rich text editor form
await type('.my-contenteditable', 'Lorem Ipsum Dolor');

// ❌ the text to type must be passed
await type('.my-contenteditable');
// ❌ The method takes two parameters and not an object
await type({selector: '.my-contenteditable', text: 'Lorem'});

Full example

'use strict';

const expect = require('chai').expect;
const { go, type, test, text } = require('testim');

test("type", async () => {
    await go('http://jsbin.testim.io/zut/1');
    const textToCheck = "Codim Self Test";
    await type('input[type=text]', textToCheck);
    const elementText = await text('#typedContent');
    expect(elementText).to.equal(textToCheck);
});

Updated 26 days ago

type(selector, textValue)


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.