Linux运行webdriver,linux - 在chrome中运行Selenium WebDriver python绑定

我在使用Selenium时遇到了问题。 对于我的项目,我必须使用Chrome。 但是,在使用Selenium启动它后,我无法连接到该浏览器。

出于某种原因,Selenium无法单独找到Chrome。 当我尝试在不包含路径的情况下启动Chrome时会发生这种情况:

Traceback (most recent call last):

File "./obp_pb_get_csv.py", line 73, in

browser = webdriver.Chrome() # Get local session of chrome

File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 46, in __init__

self.service.start()

File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 58, in start

and read up at http://code.google.com/p/selenium/wiki/ChromeDriver")

selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path. Please download from http://code.google.com/p/selenium/downloads/list and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'

为了解决这个问题,我在启动Chrome的代码中包含了Chromium路径。 但是,解释器无法找到要连接的套接字:

Traceback (most recent call last):

File "./obp_pb_get_csv.py", line 73, in

browser = webdriver.Chrome('/usr/bin/chromium') # Get local session of chrome

File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 46, in __init__

self.service.start()

File "/usr/lib64/python2.7/site-packages/selenium/webdriver/chrome/service.py", line 64, in start

raise WebDriverException("Can not connect to the ChromeDriver")

selenium.common.exceptions.WebDriverException: Message: 'Can not connect to the ChromeDriver'

我也尝试通过启动chrome来解决问题:

chromium --remote-shell-port=9222

但是,这也不起作用。

PS。 这是关于我的系统的一些信息:

www-client: chromium 15.0.874.121

dev-lang: python 2.7.2-r3 Selenium 2.11.1

OS: GNU/Linux Gentoo Kernel 3.1.0-gentoo-r1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值