rod
rod copied to clipboard
How determine browser close on mac?
Rod Version: v0.112.3
The code to demonstrate your question
go func() {
for {
_, err := proto.BrowserGetVersion{}.Call(browser)
if err != nil {
log.Println(err)
utils.Sleep(0.5)
terminateProcess(i.pid)
break
}
utils.Sleep(0.5)
}
}()
What you got
Chomium browser still not closed on mac.
What you expected to see
Wanna to close Chromium browser on mac or kill a process when the browser close button is clicked, but browser just minimized... How to detect when close button is clicked and fully close browser?
Thank you.
https://github.com/go-rod/rod/issues/447
i was found the solution that works on mac
go func() {
for {
pages, err := browser.Pages()
// _, err := proto.BrowserGetVersion{}.Call(browser)
if err != nil {
log.Println(err)
utils.Sleep(0.5)
terminateProcess(i.pid)
break
}
if len(pages) == 0 {
log.Println("zero pages")
utils.Sleep(0.5)
err := browser.Close()
if err != nil {
log.Println(err)
}
break
}
utils.Sleep(0.5)
}
}()
just checking browser pages count and if it equal 0 im just close browser, and when on mac press browser close button its not minimized it fully close the browser instance sorry for english