Skip to main content

Click

Instructs an actor who has the ability to BrowseTheWeb to scroll the given PageElement into view and then click on it.

Example widget

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

Lean Page Object describing the widget

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

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

Clicking on an element

import { actorCalled } from '@serenity-js/core'
import { Click, isSelected } from '@serenity-js/web'
import { Ensure } from '@serenity-js/assertions'

await actorCalled('Chloé')
.attemptsTo(
Click.on(Form.exampleInput()),
Ensure.that(Form.exampleInput(), isSelected()),
)

Learn more

Hierarchy

Index

Methods

staticon

  • on(pageElement: Answerable<PageElement<any>>): Interaction
  • Instantiates this Interaction.


    Parameters

    • pageElement: Answerable<PageElement<any>>

      The element to be clicked on

    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>