Class: Playwright::Mouse
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::Mouse
- Defined in:
- lib/playwright_api/mouse.rb
Overview
The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
Every ‘page` object has its own Mouse, accessible with [`property: Page.mouse`].
“‘python sync # using ‘page.mouse’ to trace a 100x100 square. page.mouse.move(0, 0) page.mouse.down() page.mouse.move(0, 100) page.mouse.move(100, 100) page.mouse.move(100, 0) page.mouse.move(0, 0) page.mouse.up() “`
Instance Method Summary collapse
-
#click(x, y, button: nil, clickCount: nil, delay: nil) ⇒ Object
Shortcut for [‘method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`].
-
#dblclick(x, y, button: nil, delay: nil) ⇒ Object
Shortcut for [‘method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`], [`method: Mouse.down`] and [`method: Mouse.up`].
-
#down(button: nil, clickCount: nil) ⇒ Object
Dispatches a ‘mousedown` event.
-
#move(x, y, steps: nil) ⇒ Object
Dispatches a ‘mousemove` event.
-
#up(button: nil, clickCount: nil) ⇒ Object
Dispatches a ‘mouseup` event.
-
#wheel(deltaX, deltaY) ⇒ Object
Dispatches a ‘wheel` event.
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#click(x, y, button: nil, clickCount: nil, delay: nil) ⇒ Object
Shortcut for [‘method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`].
21 22 23 24 25 26 27 28 |
# File 'lib/playwright_api/mouse.rb', line 21 def click( x, y, button: nil, clickCount: nil, delay: nil) wrap_impl(@impl.click(unwrap_impl(x), unwrap_impl(y), button: unwrap_impl(), clickCount: unwrap_impl(clickCount), delay: unwrap_impl(delay))) end |
#dblclick(x, y, button: nil, delay: nil) ⇒ Object
Shortcut for [‘method: Mouse.move`], [`method: Mouse.down`], [`method: Mouse.up`], [`method: Mouse.down`] and [`method: Mouse.up`].
33 34 35 |
# File 'lib/playwright_api/mouse.rb', line 33 def dblclick(x, y, button: nil, delay: nil) wrap_impl(@impl.dblclick(unwrap_impl(x), unwrap_impl(y), button: unwrap_impl(), delay: unwrap_impl(delay))) end |
#down(button: nil, clickCount: nil) ⇒ Object
Dispatches a ‘mousedown` event.
39 40 41 |
# File 'lib/playwright_api/mouse.rb', line 39 def down(button: nil, clickCount: nil) wrap_impl(@impl.down(button: unwrap_impl(), clickCount: unwrap_impl(clickCount))) end |
#move(x, y, steps: nil) ⇒ Object
Dispatches a ‘mousemove` event.
45 46 47 |
# File 'lib/playwright_api/mouse.rb', line 45 def move(x, y, steps: nil) wrap_impl(@impl.move(unwrap_impl(x), unwrap_impl(y), steps: unwrap_impl(steps))) end |
#up(button: nil, clickCount: nil) ⇒ Object
Dispatches a ‘mouseup` event.
51 52 53 |
# File 'lib/playwright_api/mouse.rb', line 51 def up(button: nil, clickCount: nil) wrap_impl(@impl.up(button: unwrap_impl(), clickCount: unwrap_impl(clickCount))) end |
#wheel(deltaX, deltaY) ⇒ Object
Dispatches a ‘wheel` event. This method is usually used to manually scroll the page. See [scrolling](../input.md#scrolling) for alternative ways to scroll.
NOTE: Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish before returning.
60 61 62 |
# File 'lib/playwright_api/mouse.rb', line 60 def wheel(deltaX, deltaY) wrap_impl(@impl.wheel(unwrap_impl(deltaX), unwrap_impl(deltaY))) end |