Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Correct CDP mouse pressure and button state for clicks and drags, and stop mouse movement from emitting synthetic release events. @TheKevinWang

### Added

### Changed
Expand Down
15 changes: 11 additions & 4 deletions zendriver/core/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ async def mouse_click(
button=cdp.input_.MouseButton(button),
buttons=buttons,
click_count=1,
force=0.5 if buttons else 0.0,
)
),
self._tab.send(
Expand All @@ -570,8 +571,9 @@ async def mouse_click(
y=center[1],
modifiers=modifiers,
button=cdp.input_.MouseButton(button),
buttons=buttons,
buttons=0,
click_count=1,
force=0.0,
)
),
)
Expand All @@ -595,9 +597,6 @@ async def mouse_move(self) -> None:
cdp.input_.dispatch_mouse_event("mouseMoved", x=center[0], y=center[1])
)
await self._tab.sleep(0.05)
await self._tab.send(
cdp.input_.dispatch_mouse_event("mouseReleased", x=center[0], y=center[1])
)

async def mouse_drag(
self,
Expand Down Expand Up @@ -646,6 +645,8 @@ async def mouse_drag(
x=start_point[0],
y=start_point[1],
button=cdp.input_.MouseButton("left"),
buttons=1,
force=0.5,
)
)

Expand All @@ -656,6 +657,8 @@ async def mouse_drag(
"mouseMoved",
x=end_point[0],
y=end_point[1],
buttons=1,
force=0.5,
)
)
elif steps > 1:
Expand All @@ -673,6 +676,8 @@ async def mouse_drag(
"mouseMoved",
x=point[0],
y=point[1],
buttons=1,
force=0.5,
)
)
await asyncio.sleep(0)
Expand All @@ -683,6 +688,8 @@ async def mouse_drag(
x=end_point[0],
y=end_point[1],
button=cdp.input_.MouseButton("left"),
buttons=0,
force=0.0,
)
)

Expand Down
5 changes: 3 additions & 2 deletions zendriver/core/tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,6 @@ async def mouse_move(
await self.flash_point(x, y)
else:
await self.sleep(0.05)
await self.send(cdp.input_.dispatch_mouse_event("mouseReleased", x=x, y=y))
if flash:
await self.flash_point(x, y)

Expand Down Expand Up @@ -1588,6 +1587,7 @@ async def mouse_click(
button=cdp.input_.MouseButton(button),
buttons=buttons,
click_count=1,
force=0.5 if buttons else 0.0,
)
)

Expand All @@ -1598,8 +1598,9 @@ async def mouse_click(
y=y,
modifiers=modifiers,
button=cdp.input_.MouseButton(button),
buttons=buttons,
buttons=0,
click_count=1,
force=0.0,
)
)
if flash:
Expand Down