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

Is it possible to specify the XY position of Click()/MustClick() on an element? #666

Closed
Jacobinski opened this issue Jul 25, 2022 · 2 comments
Labels
question Questions related to rod

Comments

@Jacobinski
Copy link
Contributor

Jacobinski commented Jul 25, 2022

In the Playwright browser automation framework, it is possible to specify the location on an element to click. This is useful for image inputs that change their actions depending on click location (ex: maps, captchas, etc).

Is it possible to achieve the same thing with go-rod?

Rod Version: v0.108.1

@Jacobinski Jacobinski added the question Questions related to rod label Jul 25, 2022
@ysmood
Copy link
Collaborator

ysmood commented Jul 25, 2022

Yes:

page.Mouse.MustMove(100, 100).MustClick(proto.InputMouseButtonLeft)

To get the element's shape location:

rod/element.go

Lines 198 to 206 in fe0a731

// Shape of the DOM element content. The shape is a group of 4-sides polygons (4-gons).
// A 4-gon is not necessary a rectangle. 4-gons can be apart from each other.
// For example, we use 2 4-gons to describe the shape below:
//
// ____________ ____________
// / ___/ = /___________/ + _________
// /________/ /________/
//
func (el *Element) Shape() (*proto.DOMGetContentQuadsResult, error) {

rod/lib/proto/a_patch.go

Lines 58 to 59 in 4bbedf8

// Center of the polygon
func (q DOMQuad) Center() Point {

@Jacobinski
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants