Skip to content

Function: setCheckbox()

ts
function setCheckbox(
   ctx: Context, 
   selector: string, 
   value?: boolean, 
options?: WaitForSelectorOptions): Promise<void>;

Defined in: src/form/form.ts:160

Check or uncheck a checkbox element.

Parameters

ParameterTypeDefault valueDescription
ctxContextundefinedContext object.
selectorstringundefinedCSS selector for the checkbox element.
valuebooleantrueSet to true to check, false to uncheck. Defaults to true.
options?WaitForSelectorOptionsundefinedOptional waiting parameters.

Returns

Promise<void>

Examples

ts
// Accept the terms of service
await setCheckbox(ctx, 'input[id="accept-tos"]');
ts
// Opt out of the marketing newsletter
await setCheckbox(ctx, 'input[id="newsletter-optin"]', false);

Matterway Assistant SDK Documentation