-
-
Notifications
You must be signed in to change notification settings - Fork 430
Open
Labels
questionQuestions related to rodQuestions related to rod
Description
Here is my code, I input a phone number, but the final result is not very good.
package main
import (
"log"
"time"
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/input"
"github.com/go-rod/rod/lib/launcher"
)
func main() {
url := launcher.New().Headless(false).MustLaunch()
browser := rod.New().ControlURL(url).MustConnect()
page := browser.MustPage()
page.MustNavigate("https://www.google.com").MustWaitLoad()
page.MustWaitLoad()
mobildInput := page.Timeout(5 * time.Second).MustElement(`textarea`)
mobildInput.MustClick()
mobildInput.MustFocus()
phone := "+212635413216"
for _, v := range phone {
time.Sleep(1 * time.Second)
log.Println(getKey(string(v)))
// page.KeyActions().Type(getKey(string(v))).MustDo()
mobildInput.MustKeyActions().Type(getKey(string(v))).MustDo()
}
select {}
}
func getKey(id string) input.Key {
keys := map[string]input.Key{
"0": input.Numpad0,
"1": input.Numpad1,
"2": input.Numpad2,
"3": input.Numpad3,
"4": input.Numpad4,
"5": input.Numpad5,
"6": input.Numpad6,
"7": input.Numpad7,
"8": input.Numpad8,
"9": input.Numpad9,
"+": input.NumpadAdd,
}
return keys[id]
}The final input result is +353
Metadata
Metadata
Assignees
Labels
questionQuestions related to rodQuestions related to rod