MCPcopy
hub / github.com/codeceptjs/CodeceptJS / forceRightClick

Method forceRightClick

lib/helper/WebDriver.js:1235–1254  ·  view source on GitHub ↗

* {{> forceRightClick }} *

(locator, context = null)

Source from the content-addressed store, hash-verified

1233 *
1234 */
1235 async forceRightClick(locator, context = null) {
1236 const locateFn = prepareLocateFn.call(this, context)
1237
1238 const res = await findClickable.call(this, locator, locateFn)
1239 if (context) {
1240 assertElementExists(res, locator, 'Clickable element', `was not found inside element ${new Locator(context)}`)
1241 } else {
1242 assertElementExists(res, locator, 'Clickable element')
1243 }
1244 const elem = usingFirstElement(res)
1245
1246 return this.executeScript(el => {
1247 if (document.activeElement instanceof HTMLElement) {
1248 document.activeElement.blur()
1249 }
1250 const event = document.createEvent('MouseEvent')
1251 event.initEvent('contextmenu', true, true)
1252 return el.dispatchEvent(event)
1253 }, elem)
1254 }
1255
1256 /**
1257 * {{> fillField }}

Calls 4

executeScriptMethod · 0.95
usingFirstElementFunction · 0.85
assertElementExistsFunction · 0.70
blurMethod · 0.45

Tested by

no test coverage detected