端口不可用。退出…用于golang selenium webdriver。

huangapple go评论81阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2015年1月5日 10:57:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/27772832.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定