Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/spoof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ export class GhostCursor {
// Exit function if the browser is no longer connected
if (!this.page.browser().isConnected()) return

log('Warning: could not move mouse, error message:', error)
log('Warning: Could not move mouse. Error message: ', error)
}
}
}
Expand Down Expand Up @@ -623,7 +623,14 @@ export class GhostCursor {
await delay(optionsResolved.waitForClick)
await this.mouseUp()
} catch (error) {
log('Warning: could not click mouse, error message:', error)
// use JS click method as a fallback
log('Warning: Could not click mouse using CDP. Falling back to JS click method. Error message: ', error)
await this.page.evaluate(() => {
const element = document.elementFromPoint(this.location.x, this.location.y) as HTMLElement | null
if (element != null) {
element.click()
}
})
}

await delay(optionsResolved.moveDelay * (optionsResolved.randomizeMoveDelay ? Math.random() : 1))
Expand Down