Skip to content

Conversation

@rn0l485
Copy link

@rn0l485 rn0l485 commented Apr 6, 2021

Hi,
I just add a function for moving the mouse to the target node.

Copy link
Member

@ZekeLu ZekeLu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And can you please add unit tests for the new funcs?





Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines





Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines





Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines





Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove extra blank lines above.

Type: input.MouseMoved,
X: x,
Y: y,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use the constructor func?

p := input.DispatchMouseEvent(input.MouseMoved, x, y)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just noticed this function here, it did the thing what I’m looking for for MouseMoveXY



func MouseMoveNode(n *cdp.Node, opts ...MouseOption) MouseAction {
return ActionFunc(func(ctx context.Context) error {
Copy link
Member

@ZekeLu ZekeLu Apr 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MouseClickNode does some check and scrolls the node into view, should we do the same here? If the answer is yes, maybe we should extract those code into a func.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MouseMoveNode function is the similar function to the MouseClickNode, but it doesn’t do the click movement, just put the mouse on the target node.

@ysmood
Copy link

ysmood commented Apr 28, 2021

@rn0l485 A better way to abstract it in Rod: https://github.com/go-rod/rod/blob/d7b838112a1a30304d0c7afd759e1a9608066a93/element.go#L72-L81

page.MustElement("button").MustHover()

Hover the mouse over the center of the element.
Before the action, it will try to scroll to the element and wait until it's interactable.

@kenshaw kenshaw closed this Apr 1, 2025
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

Successfully merging this pull request may close these issues.

4 participants