mirror of
https://github.com/playwright-community/playwright-go.git
synced 2026-06-03 21:02:27 +08:00
Some checks failed
Go / Lint (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, oldstable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, oldstable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, oldstable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, stable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, stable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (chromium, stable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, oldstable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, oldstable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, oldstable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, stable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, stable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (firefox, stable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, oldstable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, oldstable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, oldstable, windows-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, stable, macos-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, stable, ubuntu-latest) (push) Has been cancelled
Go / ${{ matrix.browser }} on ${{ matrix.os }}, go ${{ matrix.go }} (webkit, stable, windows-latest) (push) Has been cancelled
Go / test-examples (push) Has been cancelled
Docs / Deploy docs (push) Has been cancelled
Verify Types / verify (push) Has been cancelled
Go / finish (push) Has been cancelled
118 lines
2.4 KiB
Go
118 lines
2.4 KiB
Go
package playwright
|
|
|
|
type mouseImpl struct {
|
|
channel *channel
|
|
}
|
|
|
|
func newMouse(channel *channel) *mouseImpl {
|
|
return &mouseImpl{
|
|
channel: channel,
|
|
}
|
|
}
|
|
|
|
func (m *mouseImpl) Move(x float64, y float64, options ...MouseMoveOptions) error {
|
|
_, err := m.channel.Send("mouseMove", map[string]any{
|
|
"x": x,
|
|
"y": y,
|
|
}, options)
|
|
return err
|
|
}
|
|
|
|
func (m *mouseImpl) Down(options ...MouseDownOptions) error {
|
|
_, err := m.channel.Send("mouseDown", options)
|
|
return err
|
|
}
|
|
|
|
func (m *mouseImpl) Up(options ...MouseUpOptions) error {
|
|
_, err := m.channel.Send("mouseUp", options)
|
|
return err
|
|
}
|
|
|
|
func (m *mouseImpl) Click(x, y float64, options ...MouseClickOptions) error {
|
|
_, err := m.channel.Send("mouseClick", map[string]any{
|
|
"x": x,
|
|
"y": y,
|
|
}, options)
|
|
return err
|
|
}
|
|
|
|
func (m *mouseImpl) Dblclick(x, y float64, options ...MouseDblclickOptions) error {
|
|
var option MouseDblclickOptions
|
|
if len(options) == 1 {
|
|
option = options[0]
|
|
}
|
|
return m.Click(x, y, MouseClickOptions{
|
|
ClickCount: Int(2),
|
|
Button: option.Button,
|
|
Delay: option.Delay,
|
|
})
|
|
}
|
|
|
|
func (m *mouseImpl) Wheel(deltaX, deltaY float64) error {
|
|
_, err := m.channel.Send("mouseWheel", map[string]any{
|
|
"deltaX": deltaX,
|
|
"deltaY": deltaY,
|
|
})
|
|
return err
|
|
}
|
|
|
|
type keyboardImpl struct {
|
|
channel *channel
|
|
}
|
|
|
|
func newKeyboard(channel *channel) *keyboardImpl {
|
|
return &keyboardImpl{
|
|
channel: channel,
|
|
}
|
|
}
|
|
|
|
func (m *keyboardImpl) Down(key string) error {
|
|
_, err := m.channel.Send("keyboardDown", map[string]any{
|
|
"key": key,
|
|
})
|
|
return err
|
|
}
|
|
|
|
func (m *keyboardImpl) Up(key string) error {
|
|
_, err := m.channel.Send("keyboardUp", map[string]any{
|
|
"key": key,
|
|
})
|
|
return err
|
|
}
|
|
|
|
func (m *keyboardImpl) InsertText(text string) error {
|
|
_, err := m.channel.Send("keyboardInsertText", map[string]any{
|
|
"text": text,
|
|
})
|
|
return err
|
|
}
|
|
|
|
func (m *keyboardImpl) Type(text string, options ...KeyboardTypeOptions) error {
|
|
_, err := m.channel.Send("keyboardInsertText", map[string]any{
|
|
"text": text,
|
|
}, options)
|
|
return err
|
|
}
|
|
|
|
func (m *keyboardImpl) Press(key string, options ...KeyboardPressOptions) error {
|
|
_, err := m.channel.Send("keyboardPress", map[string]any{
|
|
"key": key,
|
|
}, options)
|
|
return err
|
|
}
|
|
|
|
type touchscreenImpl struct {
|
|
channel *channel
|
|
}
|
|
|
|
func newTouchscreen(channel *channel) *touchscreenImpl {
|
|
return &touchscreenImpl{
|
|
channel: channel,
|
|
}
|
|
}
|
|
|
|
func (t *touchscreenImpl) Tap(x int, y int) error {
|
|
_, err := t.channel.Send("touchscreenTap", map[string]any{"x": x, "y": y})
|
|
return err
|
|
}
|