MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / forceClick

Method forceClick

lib/helper/WebDriver.js:1096–1116  ·  view source on GitHub ↗

* {{> forceClick }} *

(locator, context = null)

Source from the content-addressed store, hash-verified

1094 *
1095 */
1096 async forceClick(locator, context = null) {
1097 const locateFn = prepareLocateFn.call(this, context)
1098
1099 const res = await findClickable.call(this, locator, locateFn)
1100 if (context) {
1101 assertElementExists(res, locator, 'Clickable element', `was not found inside element ${new Locator(context)}`)
1102 } else {
1103 assertElementExists(res, locator, 'Clickable element')
1104 }
1105 const elem = selectElement(res, locator, this)
1106 highlightActiveElement.call(this, elem)
1107
1108 return this.executeScript(el => {
1109 if (document.activeElement instanceof HTMLElement) {
1110 document.activeElement.blur()
1111 }
1112 const event = document.createEvent('MouseEvent')
1113 event.initEvent('click', true, true)
1114 return el.dispatchEvent(event)
1115 }, elem)
1116 }
1117
1118 /**
1119 * {{> doubleClick }}

Callers

nothing calls this directly

Calls 4

executeScriptMethod · 0.95
selectElementFunction · 0.90
assertElementExistsFunction · 0.70
blurMethod · 0.45

Tested by

no test coverage detected