Skip to main content

Hover

Instructs an actor who has the ability to BrowseTheWeb to hover the mouse pointer over a given PageElement.

Example widget

 <a data-test="example-link"
class="off"
onmouseover="this.className='on';"
onmouseout="this.className='off';"
href="/">hover over me</a>

Lean Page Object describing the widget

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

class Example {
static link = () =>
PageElement.located(By.css('[data-test="example-link"]'))
.describedAs('example link')
}

Hovering over an element

import { actorCalled } from '@serenity-js/core'
import { Hover, CssClasses } from '@serenity-js/web'
import { Ensure, equals } from '@serenity-js/assertions'

await actorCalled('Hank')
.whoCan(BrowseTheWeb.using(browser))
.attemptsTo(
Ensure.that(CssClasses.of(Example.link()), equals([ 'off' ])),

Hover.over(Example.link),
Ensure.that(CssClasses.of(Example.link()), equals([ 'on' ])),
)

Learn more

Hierarchy

Index

Methods

staticover

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


    Parameters

    • pageElement: Answerable<PageElement<any>>

      The element to be hovered over

    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>