import {Clear} from '@serenity-js/webdriverio/lib/screenplay/interactions'
public class | source

Clear

Instructs the Actor to clear the value of a form input.

Extends:

Interaction → Clear

Examples:

Example widget
 <form>
   <input type="text" name="example" id="example" />
 </form>
Lean Page Object describing the widget
 import { by, Target } from '@serenity-js/webdriverio';

 class Form {
     static exampleInput = Target.the('example input')
         .located(by.id('example'));
 }
Clearing the value of an input field
 import { actorCalled } from '@serenity-js/core';
 import { BrowseTheWeb, Clear, Enter, Value } from '@serenity-js/webdriverio';
 import { Ensure, equals } from '@serenity-js/assertions';

 actorCalled('Inés')
     .whoCan(BrowseTheWeb.using(browser))
     .attemptsTo(
         Enter.theValue('Hello world!').into(Form.exampleInput),
         Ensure.that(Value.of(Form.exampleInput), equals('Hello world!')),

         Clear.theValueOf(Form.exampleInput),
         Ensure.that(Value.of(Form.exampleInput), equals('')),
     );

Static Method Summary

Static Public Methods
public static

theValueOf(field: Answerable<Element<'async'>>): Interaction

Instantiates this Interaction.

Constructor Summary

Public Constructor
public

constructor(field: Answerable<Element<'async'>>)

Method Summary

Public Methods
public

async performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void>

Makes the provided Actor perform this Interaction.

Public Constructors

public constructor(field: Answerable<Element<'async'>>) source

Params:

NameTypeAttributeDescription
field Answerable<Element<'async'>>

The element to be clicked on

Public Methods

public async performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void> source

Makes the provided Actor perform this Interaction.

Params:

NameTypeAttributeDescription
actor UsesAbilities & AnswersQuestions

An Actor to perform this Interaction

Returns:

PromiseLike<void>