Skip to main content

Clear

Instructs an actor who has the ability to BrowseTheWeb to clear the value of a form input field.

Example widget

<form>
<input type="text" name="example" id="example" />
</form>

Lean Page Object describing the widget

import { By, PageElement } from '@serenity-js/web'

const Form = {
exampleInput: () =>
PageElement.located(By.id('example'))
.describedAs('example input')
}

Clearing the value of an input field

import { actorCalled } from '@serenity-js/core'
import { Clear, Enter, Value } from '@serenity-js/web'
import { Ensure, equals } from '@serenity-js/assertions'

await 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('')),
)

Learn more

Hierarchy

Index

Methods

statictheValueOf

  • theValueOf(field: Answerable<PageElement<any>>): Interaction
  • Instantiates an interaction that instructs the actor to clear the value of an input field,


    Parameters

    • field: Answerable<PageElement<any>>

      The field which value should be cleared

    Returns Interaction

instantiationLocation

  • instantiationLocation(): FileSystemLocation
  • Returns the location where this Activity was instantiated.


    Returns FileSystemLocation

toString

  • toString(): string
  • Generates a human-friendly description to be used when reporting this Activity.

    Note: When this activity is reported, token #actor in the description will be replaced with the name of the actor performing this Activity.

    For example, #actor clicks on a button becomes Wendy clicks on a button.


    Returns string

performAs

  • performAs(actor: UsesAbilities & AnswersQuestions): Promise<void>