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

Function proceedClick

lib/helper/Playwright.js:4259–4298  ·  view source on GitHub ↗
(locator, context = null, options = {})

Source from the content-addressed store, hash-verified

4257}
4258
4259async function proceedClick(locator, context = null, options = {}) {
4260 let matcher = await this._getContext()
4261 if (context) {
4262 const els = await this._locate(context)
4263 assertElementExists(els, context)
4264 matcher = els[0]
4265 }
4266 const els = await findClickable.call(this, matcher, locator)
4267 if (context) {
4268 assertElementExists(els, locator, 'Clickable element', `was not found inside element ${new Locator(context).toString()}`)
4269 } else {
4270 assertElementExists(els, locator, 'Clickable element')
4271 }
4272
4273 const opts = store.currentStep?.opts
4274 let element
4275 if (opts?.elementIndex != null) {
4276 element = selectElement(els, locator, this)
4277 } else {
4278 const strict = (opts?.exact === false || opts?.strictMode === false) ? false : (this.options.strict || opts?.exact === true || opts?.strictMode === true)
4279 if (strict) assertOnlyOneElement(els, locator, this)
4280 element = els.length > 1 ? (await getVisibleElements(els))[0] : els[0]
4281 }
4282
4283 await highlightActiveElement.call(this, element)
4284 if (store.debugMode) this.debugSection('Clicked', await elToString(element, 1))
4285
4286 if (options.force) {
4287 await element.dispatchEvent('click')
4288 } else {
4289 await element.click(options)
4290 }
4291 const promises = []
4292 if (options.waitForNavigation) {
4293 promises.push(this.waitForURL(/.*/, { waitUntil: options.waitForNavigation }))
4294 }
4295 promises.push(this._waitForAction())
4296
4297 return Promise.all(promises)
4298}
4299
4300async function findClickable(matcher, locator) {
4301 const matchedLocator = new Locator(locator)

Callers

nothing calls this directly

Calls 12

selectElementFunction · 0.90
getVisibleElementsFunction · 0.85
elToStringFunction · 0.85
pushMethod · 0.80
waitForURLMethod · 0.80
assertElementExistsFunction · 0.70
assertOnlyOneElementFunction · 0.70
_getContextMethod · 0.45
_locateMethod · 0.45
toStringMethod · 0.45
clickMethod · 0.45
_waitForActionMethod · 0.45

Tested by

no test coverage detected