* 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)
| 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 }} |
no test coverage detected