import {Hover} from '@serenity-js/protractor/lib/screenplay/interactions'
public class | source

Hover

Instructs the Actor to hover the mouse pointer over a given Web element.

Extends:

Interaction → Hover

Examples:

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 { Target } from '@serenity-js/protractor';
 import { by } from 'protractor';

 class Example {
     static link = Target.the('example link')
         .located(by.css('[data-test="example-link"]'));
 }
Hovering over an element
 import { actorCalled } from '@serenity-js/core';
 import { BrowseTheWeb, Hover, CSSClasses } from '@serenity-js/protractor';
 import { Ensure, equals } from '@serenity-js/assertions';
 import { protractor } from 'protractor';

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

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

Tests:

Static Method Summary

Static Public Methods
public static

over(target: Question<ElementFinder> | ElementFinder): Interaction

Instantiates this Interaction.

Constructor Summary

Public Constructor
public

constructor(target: Question<ElementFinder> | ElementFinder)

Method Summary

Public Methods
public

performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void>

Makes the provided Actor perform this Interaction.

public

toString(): string

Generates a description to be used when reporting this Activity.

Static Public Methods

public static over(target: Question<ElementFinder> | ElementFinder): Interaction source

Instantiates this Interaction.

Params:

NameTypeAttributeDescription
target Question<ElementFinder> | ElementFinder

The element to be hovered over

Returns:

Interaction

Public Constructors

public constructor(target: Question<ElementFinder> | ElementFinder) source

Params:

NameTypeAttributeDescription
target Question<ElementFinder> | ElementFinder

The element to be hovered over

Public Methods

public performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void> source

Makes the provided Actor perform this Interaction.

Params:

NameTypeAttributeDescription
actor UsesAbilities & AnswersQuestions

An Actor to perform this Interaction

Returns:

PromiseLike<void>

public toString(): string source

Generates a description to be used when reporting this Activity.

Returns:

string