* Clicks on a locator or XY vector. This method is made because of the difference between ghost-cursor-playwright and Playwright methods
(target: Locator|Page, position?: { x: number, y: number })
| 215 | * Clicks on a locator or XY vector. This method is made because of the difference between ghost-cursor-playwright and Playwright methods |
| 216 | */ |
| 217 | private async click(target: Locator|Page, position?: { x: number, y: number }): Promise<void> { |
| 218 | if (this.ghostCursorEnabled) { |
| 219 | let pos: any = isPage(target) ? { x: 0, y: 0 } : await target.boundingBox(); |
| 220 | if (position) |
| 221 | pos = { |
| 222 | ...pos, |
| 223 | x: pos.x + position.x, |
| 224 | y: pos.y + position.y, |
| 225 | width: null, |
| 226 | height: null, |
| 227 | }; |
| 228 | return this.cursor?.actions.click({ |
| 229 | target: pos |
| 230 | }); |
| 231 | } else { |
| 232 | if (isPage(target)) |
| 233 | return target.mouse.click(position?.x ?? 0, position?.y ?? 0); |
| 234 | else |
| 235 | return target.click({ force: true, position }); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Get the BrowserType from the `BROWSER` environment variable. |