Progress at getting SendKeys to send arrow keys
This commit is contained in:
@@ -23,8 +23,8 @@ func main() {
|
||||
}
|
||||
|
||||
// run task list
|
||||
var val1, val2, val3 string
|
||||
err = c.Run(ctxt, sendkeys(&val1, &val2, &val3))
|
||||
var val1, val2, val3, val4 string
|
||||
err = c.Run(ctxt, sendkeys(&val1, &val2, &val3, &val4))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -44,18 +44,21 @@ func main() {
|
||||
log.Printf("#input1 value: %s", val1)
|
||||
log.Printf("#textarea1 value: %s", val2)
|
||||
log.Printf("#input2 value: %s", val3)
|
||||
log.Printf("#select1 value: %s", val4)
|
||||
}
|
||||
|
||||
func sendkeys(val1, val2, val3 *string) cdp.Tasks {
|
||||
func sendkeys(val1, val2, val3, val4 *string) cdp.Tasks {
|
||||
return cdp.Tasks{
|
||||
cdp.Navigate("file:" + os.Getenv("GOPATH") + "/src/github.com/knq/chromedp/testdata/visible.html"),
|
||||
cdp.WaitVisible(`#input1`, cdp.ByID),
|
||||
cdp.WaitVisible(`#textarea1`, cdp.ByID),
|
||||
cdp.SendKeys(`#textarea1`, "\b\b\n\naoeu\n\ntest1\n\nblah2\n\n\t\b\bother box!\t\ntest4", cdp.ByID),
|
||||
cdp.SendKeys(`#textarea1`, "\b\b\n\naoeu\n\ntest1\n\nblah2\n\n\t\t\t\b\bother box!\t\ntest4", cdp.ByID),
|
||||
cdp.Value(`#input1`, val1, cdp.ByID),
|
||||
cdp.Value(`#textarea1`, val2, cdp.ByID),
|
||||
cdp.SetValue(`#input2`, "test3", cdp.ByID),
|
||||
cdp.Value(`#input2`, val3, cdp.ByID),
|
||||
cdp.SendKeys(`#select1`, cdp.KeyCodeDown+cdp.KeyCodeDown, cdp.ByID),
|
||||
cdp.Value(`#select1`, val4, cdp.ByID),
|
||||
cdp.Sleep(30 * time.Second),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user