Skip to main content

Enter

Instructs an actor who has the ability to BrowseTheWeb to enter a value into 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'

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

Entering the value into a form field

import { actorCalled } from '@serenity-js/core';
import { Enter } from '@serenity-js/web';

await actorCalled('Esme')
.attemptsTo(
Enter.theValue('Hello world!').into(Form.exampleInput()),
)

Handling sensitive information

By design, any data handled by an actor appears in Serenity/JS reports. To prevent the exposure of any sensitive information, such as passwords or tokens, you should use Masked.

import { actorCalled, Masked } from '@serenity-js/core'
import { Enter } from '@serenity-js/web'

await actorCalled('Esme')
.attemptsTo(
Enter.theValue(Masked.valueOf('your little secret').into(Form.exampleInputField()),
)

// Gets reported as: "Esme enters [a masked value] into the example input field"

Learn more

Hierarchy

Index

Methods

statictheValue

  • theValue(...values: Answerable<string | number | string[] | number[]>[]): { into: (field: Answerable<PageElement<any>>) => Interaction }
  • Instantiates this Interaction.


    Parameters

    • rest...values: Answerable<string | number | string[] | number[]>[]

      The text value to be entered

    Returns { into: (field: Answerable<PageElement<any>>) => Interaction }

    • into: (field: Answerable<PageElement<any>>) => Interaction
        • Parameters

          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>