Issue
I starting to learn selenium in golang and trying to scrape web page with it but when i run my app i got this error:
error:exec: "./chromedriver": file does not exist exit status 1
This is my code snippets :
// initialize a Chrome browser instance on port 4444
service, err := selenium.NewChromeDriverService("./chromedriver", 4444)
if err != nil {
log.Fatal("Error:", err)
}
defer service.Stop()
// configure the browser options
caps := selenium.Capabilities{}
caps.AddChrome(chrome.Capabilities{Args: []string{
"--headless-new", // comment out this line for testing
}})
// create a new remote client with the specified options
driver, err := selenium.NewRemote(caps, "")
if err != nil {
log.Fatal("Error:", err)
}
// maximize the current window to avoid responsive rendering
err = driver.MaximizeWindow("")
if err != nil {
log.Fatal("Error:", err)
}
Note that im using windows machine.
I think it works on linux machine, but im really confused 😕
Solution
I solved the problem by downloading driver form here and moving it in project directory.
You can also add driver to PATH
for using it in projects.
Answered By - Sayed Mahdi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.