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