Note
This is currently WIP.
User input currently consist of simulating mouse clicks and keyboard interaction. These interactions triggers default behaviour in many elements.
To simulate user input, use the KeyboardController type. Example:
b := browser.New()
win := b.Open("http://example.com")
input := win.Document().QueryElement("#fullname-input")
input.(html.HTMLElement).Focus()
ctrl := KeyboardController{Window: win}
ctrl.SendKeys(keys.StringToKeys("John Smith"))
assert.Equal(t, "John Smith", input.Value())Input is directed goes to the currently focused element. here Element.focus is explicitly called to bring focus to the element.
Important
It is currently clear that the design is not sufficient, as modifier keys have
not been taken into consideration. So the design might change. But the
operation SendKeys(key.StringToKeys("input")) should stay valid as a whole.
Keyboard simulation is in a very early stage.
- Modifier keys
- Moving focus on tab/shift+tab.
- Clicking buttons on space.
- Submitting forms on enter.