(locator, context = null, options = {})
| 4257 | } |
| 4258 | |
| 4259 | async 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 | |
| 4300 | async function findClickable(matcher, locator) { |
| 4301 | const matchedLocator = new Locator(locator) |
nothing calls this directly
no test coverage detected