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

add the MouseMoveNode function #787

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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.

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.

None yet

3 participants