Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing element's point that should be clicked instead of calculating a random point #151

Open
vworld opened this issue Nov 24, 2024 · 0 comments

Comments

@vworld
Copy link

vworld commented Nov 24, 2024

The library is good and I love what you have done. An additional option could be to allow an X and Y point relative to the element that should be clicked instead of calculating the point randomly.

This would help when

  • more control on the exact click point is required
  • implementing a custom random point selection method
  • performing additional checks on a selected point before the click is done

For example, this would allow checking if the point that will be clicked is indeed the element that must be clicked, is active and not occluded by some other elements; thereby making the action predictable. This would also solve/provide a robust alternative for Issue #120 #109 where users can implement their own method to select the point.

So the MoveOptions interface can include

  {
    /** X and Y points relative to the top-left corner of the element */
    clickDestination: {X: number, Y: number}
  }

and the destination calculation would be

// const destination = getRandomBoxPoint(box, optionsResolved)
const destination = {x: box.x + options.clickDestination.x, y: box.y + options.clickDestination.y}

If you approve, I can submit a pull request.

@vworld vworld changed the title Allow passing element's point that shuold be clicked instead of calculating a random point Allow passing element's point that should be clicked instead of calculating a random point Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant