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

Method clickXY

lib/helper/Puppeteer.js:1437–1460  ·  view source on GitHub ↗

* Performs click at specific coordinates. * If locator is provided, the coordinates are relative to the element. * If locator is not provided, the coordinates are global page coordinates. * * ```js * // Click at global coordinates (100, 200) * I.clickXY(100, 200); * * // Clic

(locator, x, y)

Source from the content-addressed store, hash-verified

1435 * @returns {Promise<void>}
1436 */
1437 async clickXY(locator, x, y) {
1438 // If locator is a number, treat it as global X coordinate
1439 if (typeof locator === 'number') {
1440 const globalX = locator
1441 const globalY = x
1442 await this.page.mouse.click(globalX, globalY)
1443 return this._waitForAction()
1444 }
1445
1446 // Locator is provided, click relative to element
1447 const els = await this._locate(locator)
1448 assertElementExists(els, locator, 'Element to click')
1449
1450 const box = await els[0].boundingBox()
1451 if (!box) {
1452 throw new Error(`Element ${locator} is not visible or has no bounding box`)
1453 }
1454
1455 const absoluteX = box.x + x
1456 const absoluteY = box.y + y
1457
1458 await this.page.mouse.click(absoluteX, absoluteY)
1459 return this._waitForAction()
1460 }
1461
1462 /**
1463 * {{> checkOption }}

Callers 1

testsFunction · 0.45

Calls 4

_waitForActionMethod · 0.95
_locateMethod · 0.95
assertElementExistsFunction · 0.70
clickMethod · 0.45

Tested by

no test coverage detected