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

describedBy

  • describedBy(actor: AnswersQuestions & UsesAbilities & { name: string }): Promise<string>
  • Resolves the description of this object in the context of the provided actor.


    Parameters

    • actor: AnswersQuestions & UsesAbilities & { name: string }

    Returns Promise<string>

toString

  • toString(): string
  • Returns a human-readable description of this object.


    Returns string

performAs

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