This is a TDK feature

This is not supported in Testim's visual editor

This method is used to check if a radio element is checked or not.

  • selector {string | TDKStepLocator} a CSS selector or smart locator.
  • returns: Promise that fulfills with whtehr or not this radio button is checked
// ✅ check that a given radio selected
const isChecked = await radio('input[type=radio]');
expect(isChecked).to.equal(true); // for example with an assertion library

// ✅ same with locator
const isChecked = await radio(l('input[type=radio]'));
expect(isChecked).to.equal(true); // for example with an assertion library

// ❌ need to check the return value and perform an assertion
await checkbox('.signed-up');

Full Example:

'use strict';

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

test("radio button", async () => {
    await go'use strict';('');
    await click('#first')
    let firstChecked = await radio('#first');
    let secondChecked = await radio('#second');
    await click('#second')
    firstChecked = await radio('#first');
    secondChecked = await radio('#second');