feat: browser binary path as parameter
This commit is contained in:
parent
abf360a126
commit
d69bfe4590
20
main.go
20
main.go
|
@ -22,6 +22,7 @@ func main() {
|
|||
|
||||
config := cfg.NewConfig(envFile)
|
||||
log.SetFlags(log.Lmicroseconds)
|
||||
config.LogFile = false
|
||||
if config.LogFile {
|
||||
logFileName := fmt.Sprintf("%s.txt", time.Now().Format(strings.ReplaceAll(time.RFC1123Z, ":", "_")))
|
||||
f, err := os.OpenFile(logFileName, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644)
|
||||
|
@ -33,21 +34,30 @@ func main() {
|
|||
log.SetOutput(f)
|
||||
}
|
||||
|
||||
// get the browser executable path
|
||||
var lc *launcher.Launcher
|
||||
var u string
|
||||
|
||||
if config.Bin != "" {
|
||||
lc = launcher.New().Bin(config.Bin)
|
||||
u = lc.MustLaunch()
|
||||
log.Println("u = lc.MustLaunch()", u)
|
||||
} else {
|
||||
lc = launcher.New()
|
||||
path := launcher.NewBrowser().MustGet()
|
||||
args := launcher.New().FormatArgs()
|
||||
args := lc.FormatArgs()
|
||||
|
||||
cmd := leakless.New().Command(path, args...)
|
||||
|
||||
parser := launcher.NewURLParser()
|
||||
cmd.Stderr = parser
|
||||
utils.E(cmd.Start())
|
||||
u := launcher.MustResolveURL(<-parser.URL)
|
||||
u = launcher.MustResolveURL(<-parser.URL)
|
||||
}
|
||||
|
||||
browser := rod.New().
|
||||
ControlURL(u).
|
||||
MustConnect().
|
||||
MustIgnoreCertErrors(true)
|
||||
|
||||
defer browser.MustClose()
|
||||
|
||||
page := browser.MustPage(config.Page)
|
||||
|
@ -71,7 +81,7 @@ func main() {
|
|||
mainFrame := page.MustElement("#mainFrame").MustFrame()
|
||||
mainFrame.MustElement("#wlanEnable").MustClick()
|
||||
log.Println("wlanEnable DONE")
|
||||
return
|
||||
|
||||
mainFrame.MustElement("#sysSubmit").MustClick()
|
||||
// TODO: improve this and wait until something should happens (refresh)
|
||||
time.Sleep(time.Second * 3)
|
||||
|
|
Loading…
Reference in New Issue