Class: Playwright::Mouse

Inherits:
PlaywrightApi show all
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

Methods inherited from PlaywrightApi

#initialize, unwrap, wrap

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`].



19
20
21
22
23
24
25
26
# File 'lib/playwright_api/mouse.rb', line 19

def click(
      x,
      y,
      button: nil,
      clickCount: nil,
      delay: nil)
  wrap_impl(@impl.click(unwrap_impl(x), unwrap_impl(y), button: unwrap_impl(button), 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`].



30
31
32
# File 'lib/playwright_api/mouse.rb', line 30

def dblclick(x, y, button: nil, delay: nil)
  wrap_impl(@impl.dblclick(unwrap_impl(x), unwrap_impl(y), button: unwrap_impl(button), delay: unwrap_impl(delay)))
end

#down(button: nil, clickCount: nil) ⇒ Object

Dispatches a ‘mousedown` event.



35
36
37
# File 'lib/playwright_api/mouse.rb', line 35

def down(button: nil, clickCount: nil)
  wrap_impl(@impl.down(button: unwrap_impl(button), clickCount: unwrap_impl(clickCount)))
end

#move(x, y, steps: nil) ⇒ Object

Dispatches a ‘mousemove` event.



40
41
42
# File 'lib/playwright_api/mouse.rb', line 40

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.



45
46
47
# File 'lib/playwright_api/mouse.rb', line 45

def up(button: nil, clickCount: nil)
  wrap_impl(@impl.up(button: unwrap_impl(button), clickCount: unwrap_impl(clickCount)))
end

#wheel(deltaX, deltaY) ⇒ Object

Dispatches a ‘wheel` event.

> NOTE: Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish before returning.



53
54
55
# File 'lib/playwright_api/mouse.rb', line 53

def wheel(deltaX, deltaY)
  wrap_impl(@impl.wheel(unwrap_impl(deltaX), unwrap_impl(deltaY)))
end