panic: runtime error: invalid memory address or nil pointer Golang

-2

I'm trying to create a webserver using a Golang library "github.com/tebeka/selenium" as you can see below

// Setup Selenium
const (
    seleniumURL = "http://192.168.1.3:4444/wd/hub"
)
caps := selenium.Capabilities{
    "browserName": "chrome",
}
chromeOptions := chrome.Capabilities{
    Args: []string{
        //"--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",

        "--user-agent=Applebot",
        "--lang=en_US",
        "--headless",
        "--window-size=1376,768",
    },
    ExcludeSwitches: []string{
        "enable-automation",
    },
}
caps.AddChrome(chromeOptions)
// Create the web driver

driver, err := selenium.NewRemote(caps, seleniumURL)
defer driver.Quit()
errChk(err)

But I'm getting this error:

panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x6558d0]

Could you anyone help me? I really don't know what it could be

UPDATE

I put "errChk(err)" first so I could see the error

driver, err := selenium.NewRemote(caps, "http://192.168.1.3:4444/wd/hub")
errChk(err)
defer driver.Quit()

The error that I got was:

Post "http://192.168.1.3:4444/wd/hub/session": dial tcp 192.168.1.3:4444: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 2021/04/25 19:00:22 Post "http://192.168.1.3:4444/wd/hub/session": dial tcp 192.168.1.3:4444: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. exit status 1

Update 2

I was having issues because standalone server was not running make sure that it does and you will probably solve your problem.

selenium
go
webserver
asked on Stack Overflow Apr 25, 2021 by Lucas Eduardo Coelho • edited Apr 27, 2021 by Lucas Eduardo Coelho

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0