英文:
Port not available. Exiting... for golang selenium webdriver
问题
我使用selenium golang webdriver的示例代码。
package main
import (
"github.com/fedesog/webdriver"
"log"
"time"
)
func main() {
chromeDriver := webdriver.NewChromeDriver("/path/To/Chrome/Driver/chromedriver")
err := chromeDriver.Start()
if err != nil {
log.Println(err)
}
desired := webdriver.Capabilities{"Platform": "Linux"}
required := webdriver.Capabilities{}
session, err := chromeDriver.NewSession(desired, required)
if err != nil {
log.Println(err)
}
err = session.Url("http://golang.org")
if err != nil {
log.Println(err)
}
time.Sleep(10 * time.Second)
session.Delete()
chromeDriver.Stop()
}
它能够运行,但是输出了错误信息:
Port not available. Exiting..
完整的输出信息如下:
Starting ChromeDriver (v2.9.248307) on port 9515
Port not available. Exiting...
英文:
I use selenium golang webdriver example.
package main
import (
"github.com/fedesog/webdriver"
"log"
"time"
)
func main() {
chromeDriver := webdriver.NewChromeDriver("/path/To/Chrome/Driver/chromedriver")
err := chromeDriver.Start()
if err != nil {
log.Println(err)
}
desired := webdriver.Capabilities{"Platform": "Linux"}
required := webdriver.Capabilities{}
session, err := chromeDriver.NewSession(desired, required)
if err != nil {
log.Println(err)
}
err = session.Url("http://golang.org")
if err != nil {
log.Println(err)
}
time.Sleep(10 * time.Second)
session.Delete()
chromeDriver.Stop()
}
It works but logs error:
Port not available. Exiting..
Full output is :
Starting ChromeDriver (v2.9.248307) on port 9515
Port not available. Exiting...
答案1
得分: 2
看起来fedesog/webdriver正在尝试在端口9515上打开一个监听器,但是失败了:
https://github.com/fedesog/webdriver/blob/master/chromedriver.go
你可以尝试切换端口,或者查看一下是否有任何东西阻止了你的机器上的该端口。
英文:
It looks as though the fedesog/webdriver is trying to open up a listener on port 9515 and that is failing:
https://github.com/fedesog/webdriver/blob/master/chromedriver.go
You could try switching ports or seeing what if anything might be blocking that port on your machine.
答案2
得分: 0
请尝试检查chromedriver的日志或从控制台运行它。
可能是一些包依赖问题,比如dbus。
英文:
Try to check chromedriver log or run it from console.
It maybe some package dependencies like dbus.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论