Skip to main content

DoubleClick

Instructs an actor who has the ability to BrowseTheWeb to perform a double click on a given PageElement.

Example widget

<!--
The editor shows up when the user double-clicks
on one of the properties of their profile
and lets them change the value of that property.
-->
<div id="user-profile">
<ul>
<li id="display-name" ondblclick="edit(this)">User12345</li>
<li id="email-address" ondblclick="edit(this)">tester@example.org</li>
</ul>
<form id="editor" class="hidden">
<input type="text" value="" />
</form>
</div>

Lean Page Object describing the widget

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

class UserProfile {
static displayName = () =>
PageElement.located(by.id('display-name'))
.describedAs('display name')

static emailAddress = () =>
PageElement.located(by.id('email-address'))
.describedAs('email address')

static editor = () =>
PageElement.located(by.id('editor'))
.describedAs('editor')
}

Double-clicking on an element

import { actorCalled, Wait } from '@serenity-js/core'
import { DoubleClick, isVisible, Enter, Text } from '@serenity-js/web'
import { Ensure, equals, not } from '@serenity-js/assertions'

await actorCalled('Dorothy')
.whoCan(BrowseTheWeb.using(browser))
.attemptsTo(
DoubleClick.on(UserProfile.displayName),
Wait.until(UserProfile.editor(), isVisible()),

Enter.theValue('New username').into(UserProfile.editor),

Ensure.that(Text.of(UserProfile.displayName()), equals('New username')),
Ensure.that(UserProfile.editor, not(isVisible()))
)

Learn more

Hierarchy

Index

Methods

staticon

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


    Parameters

    • pageElement: Answerable<PageElement<any>>

      The element to be double-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>