Appearance
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
| Parameter | Type | Default value | Description |
|---|---|---|---|
ctx | Context | undefined | Context object. |
selector | string | undefined | CSS selector for the checkbox element. |
value | boolean | true | Set to true to check, false to uncheck. Defaults to true. |
options? | WaitForSelectorOptions | undefined | Optional 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);