Skip to main content

externalRightClick

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

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.

Example widget

<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>

Lean Page Object describing the widget

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

class Form {
static exampleInput = () =>
PageElement.located(By.id('example'))
.describedAs('example input')

static exampleContextMenu = () =>
PageElement.located(By.id('context-menu'))
.describedAs('example context menu')
}

Right-click on an element

import { actorCalled } from '@serenity-js/core'
import { RightClick, isVisible } from '@serenity-js/web'
import { Ensure } from '@serenity-js/assertions'

await actorCalled('Chloé')
.whoCan(BrowseTheWeb.using(browser))
.attemptsTo(
RightClick.on(Form.exampleInput()),
Ensure.that(Form.exampleContextMenu(), isVisible()),
)

Learn more

Hierarchy

Index

Methods

staticexternalon

externalinstantiationLocation

  • instantiationLocation(): FileSystemLocation
  • Returns the location where this Activity was instantiated.


    Returns FileSystemLocation

externaldescribedBy

  • Resolves the description of this object in the context of the provided actor.


    Parameters

    Returns Promise<string>

externaltoString

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


    Returns string

externalperformAs