This is a TDK feature

This is not supported in Testim's visual editor

This method selects a given <option> element from an HTML <select> element.

  • selector {string | TDKStepLocator} a CSS selector or smart locator for the option element
  • returns: Promise that fulfills when the action is complete.

For example:

// ✅ select the given <option> with class option3
await selectOption('.option3');
// ✅ set an element's option by a smart locator
await selectOption(l('best-option'));
// ❌ need to pass the option and not the select
await selectOption('select');

Full Example:

'use strict';

const expect = require('chai').expect;
const { go, it, describe, selectOption, evaluate } = require('testim');

describe('selectOption', () => {
    it('selects correctly', async () => {

        await go('');
        await selectOption('option:nth-child(3)');

        const value = await evaluate(() => {
            return document.querySelector('select').value;