MCPcopy
hub / github.com/go-rod/rod / TestKeyActions

Function TestKeyActions

input_test.go:12–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestKeyActions(t *testing.T) {
13 g := setup(t)
14
15 p := g.page.MustNavigate(g.srcFile("fixtures/keys.html"))
16 body := p.MustElement("body")
17
18 p.KeyActions().Press(input.ControlLeft).Type(input.Enter).MustDo()
19 g.Eq(body.MustText(), `↓ "Control" ControlLeft 17 modifiers(ctrl)
20"Enter" Enter 13 modifiers(ctrl)
21"Enter" Enter 13 modifiers(ctrl)
22"Control" ControlLeft 17 modifiers()
23`)
24
25 body.MustEval("() => this.innerText = ''")
26 body.MustKeyActions().
27 Press(input.ShiftLeft).Type('A', 'X').Release(input.ShiftLeft).
28 Type('a').MustDo()
29 g.Eq(body.MustText(), `↓ "Shift" ShiftLeft 16 modifiers(shift)
30"A" KeyA 65 modifiers(shift)
31"A" KeyA 65 modifiers(shift)
32"X" KeyX 88 modifiers(shift)
33"X" KeyX 88 modifiers(shift)
34"Shift" ShiftLeft 16 modifiers()
35"a" KeyA 65 modifiers()
36"a" KeyA 65 modifiers()
37`)
38
39 g.Nil(p.Keyboard.Release('a'))
40}
41
42func TestKeyType(t *testing.T) {
43 g := setup(t)

Callers

nothing calls this directly

Calls 12

setupFunction · 0.85
MustNavigateMethod · 0.80
srcFileMethod · 0.80
MustTextMethod · 0.80
MustKeyActionsMethod · 0.80
MustElementMethod · 0.45
MustDoMethod · 0.45
TypeMethod · 0.45
PressMethod · 0.45
KeyActionsMethod · 0.45
MustEvalMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…