import {RightClick} from '@serenity-js/webdriverio/lib/screenplay/interactions'
RightClick
Instructs the Actor to perfom a right click on a given Web element.
This is typically used to open a custom context menu on a given Web element, since it's not possible to interact with the standard context menu offered by your browser
Extends:
Examples:
<form>
<input type="text" id="field"
oncontextmenu="showMenu(); return false;" />
<div id="context-menu" style="display:none">
Custom context menu
</div>
</form>
<script>
function showMenu() {
document.getElementById("context-menu").style.display = 'block';
}
</script>
import { by, Target } from '@serenity-js/webdriverio';
class Form {
static exampleInput = Target.the('example input')
.located(by.id('example'));
static exampleContextMenu = Target.the('example context menu')
.located(by.id('context-menu'));
}
import { actorCalled } from '@serenity-js/core';
import { BrowseTheWeb, RightClick, isVisible } from '@serenity-js/webdriverio';
import { Ensure } from '@serenity-js/assertions';
actorCalled('Chloé')
.whoCan(BrowseTheWeb.using(browser))
.attemptsTo(
RightClick.on(Form.exampleInput),
Ensure.that(Form.exampleContextMenu, isVisible()),
);
Tests:
See also:
Static Method Summary
Static Public Methods | ||
public static |
on(target: Answerable<Element<'async'>>): Interaction Instantiates this Interaction. |
Constructor Summary
Public Constructor | ||
public |
constructor(target: Answerable<Element<'async'>>) |
Method Summary
Public Methods | ||
public |
async performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void> Makes the provided Actor perform this Interaction. |
Inherited Summary
From class WebElementInteraction | ||
public |
toString(): string Generates a description to be used when reporting this Activity. |
|
protected |
async resolve(actor: AnswersQuestions, element: Answerable<Element<'async'>>): Promise<Element<'async'>> Returns the resolved Element, or throws a LogicError
if the element is |
Static Public Methods
public static on(target: Answerable<Element<'async'>>): Interaction source
Instantiates this Interaction.
Params:
Name | Type | Attribute | Description |
target | Answerable<Element<'async'>> | The element to be right-clicked on |
Public Constructors
public constructor(target: Answerable<Element<'async'>>) source
Override:
WebElementInteraction#constructorParams:
Name | Type | Attribute | Description |
target | Answerable<Element<'async'>> | The element to be right-clicked on |
Public Methods
public async performAs(actor: UsesAbilities & AnswersQuestions): PromiseLike<void> source
Makes the provided Actor perform this Interaction.
Params:
Name | Type | Attribute | Description |
actor | UsesAbilities & AnswersQuestions | An Actor to perform this Interaction |
Returns:
PromiseLike<void> |