I have my Chrome browser and I want to automate some actions using chromedriver
. But when I use my default profile (default user or new "bot" profile) I always start with cleared cookies for that profile.
Can I automate existing Chrome user activity with chromedriver
?
Here is code example:
package chrome
import (
"fmt"
"github.com/sclevine/agouti"
"time"
)
func getDriver() (driver *agouti.WebDriver, stop func(), err error) {
chromeOptions := []string{
"--user-data-dir=/Users/robbo/Library/Application Support/Google/Chrome",
"--profile-directory=Profile 1",
}
driver = agouti.ChromeDriver(agouti.ChromeOptions("args", chromeOptions))
if err = driver.Start(); err != nil {
return
}
stop = func() {
_ = driver.Stop()
}
return
}
func NavigateToPageWithSession(project string) (err error) {
driver, stop, err := getDriver()
if err != nil {
return
}
defer stop()
page, err := driver.NewPage()
if err != nil {
return
}
url := fmt.Sprintf("https://stackoverflow.com/")
err = page.Navigate(url)
return
}