I'm using the go selenium package: https://github.com/tebeka/selenium
and using the phantomjs browser:
caps := selenium.Capabilities{
"browserName": "phantomjs",
}
wd, err := selenium.NewRemote(caps, "")
if err != nil {
log.Fatal(err)
}
I'm trying to also send along some phantomjs settings so I can set the user-agent string. I'm trying to make a crawler and certain websites won't load with a headless browser user-agent. I know this can be done with python and other languages but I haven't seen any examples in go.
You should set driver binary path and browser name:
caps := selenium.Capabilities{
"browserName": "phantomjs", // "chrome", or any other
"phantomjs.binary.path": "/path/to/phantomjs", // path to binary from http://phantomjs.org/
}
PhantomJS should be installed in your system.