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

sendCharacter(selector, key)

Send a given key to the browser (for example tab):

  • selector {string | TDKStepLocator} a CSS selector or smart locator for the input element
  • keyCode {number|string} the key code or character to send to the browser
  • returns: Promise that fulfills when the character has been entered

For example:

// ✅ send the first input on the page a tab key
await sendCharacter('input', '\t');
// ✅ send the first input on the page a newline
await sendCharacter('input', '\n');
// ✅ send the first input on the page a newline in ascii char code
await sendCharacter('input', 10);

// ✅ send the first input on the page a newline in ascii char code
await sendCharacter('input', 65);

// ❌ bad, use `type('input', 'hello')` instead
for(const item of [72, 101, 108, 108, 111]) {
  await sendCharacter('input', item);
}
// ❌ bad, the second character is ignored
await sendCharacter('input', 'hi')

Full Example:

'use strict';

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

test("send character", async () => {
    await go('http://jsbin.testim.io/rum/');
    await click('button');
    await sendCharacter('button', '\r');
    await sendCharacter('button', 9);
    await sendCharacter('button', 9);
    await sendCharacter('button', 13);

    const allKeys = await text('div');

    expect(allKeys).to.eq('139913');
});

Updated 26 days ago

sendCharacter(selector, key)


Suggested Edits are limited on API Reference Pages

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