chromedriver 的 python-selenium 绑定错误 [英] Error in python-selenium bindings for chromedriver

查看:28
本文介绍了chromedriver 的 python-selenium 绑定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过查看帖子此处.如帖子中所示,我为 python 下载了 chrome-driver 64-bit.我将 chromedriver 可执行文件移动到 /usr/bin,并尝试了以下代码

I am trying to create an instance of chrome driver after installing chrome driver successfully by seeing the post here. As shown in the post i downloaded chrome-driver 64-bit for python. And i moved the chromedriver executable file to /usr/bin, and tried the following code

 from selenium import webdriver
 driver = webdriver.Chromedriver()

结果:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/home/local/user/<ipython console> in <module>()

AttributeError: 'module' object has no attribute 'Chromedriver'

也当尝试以下

 from selenium import webdriver
 driver = webdriver.Firefox()

结果:

WebDriverException                        Traceback (most recent call last)

/home/local/<ipython console> in <module>()

/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout)
     49         RemoteWebDriver.__init__(self,
     50             command_executor=ExtensionConnection("127.0.0.1", self.profile,
---> 51             self.binary, timeout),
     52             desired_capabilities=DesiredCapabilities.FIREFOX)
     53 

/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/extension_connection.pyc in __init__(self, host, firefox_profile, firefox_binary, timeout)
     45         self.profile.add_extension()
     46 
---> 47         self.binary.launch_browser(self.profile)
     48         _URL = "http://%s:%d/hub" % (HOST, PORT)
     49         RemoteConnection.__init__(

/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.pyc in launch_browser(self, profile)
     42 
     43         self._start_from_profile_path(self.profile.path)
---> 44         self._wait_until_connectable()
     45 
     46     def kill(self):

/usr/lib/python2.7/site-packages/selenium-2.21.3-py2.7.egg/selenium/webdriver/firefox/firefox_binary.pyc in _wait_until_connectable(self)
     79                 raise WebDriverException("The browser appears to have exited "
     80                       "before we could connect. The output was: %s" %
---> 81                       self._get_firefox_output())
     82             if count == 30:
     83                 self.kill()

WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: *** LOG addons.xpi: startup\n*** LOG addons.xpi: checkForChanges\n*** LOG addons.xpi: Opening database\n*** LOG addons.xpi: No changes found\nFailed to dlopen /usr/lib/libX11.so.6\ndlerror says: /usr/lib/libX11.so.6: wrong ELF class: ELFCLASS32\n' 

我不知道这里发生了什么,以及为什么 chrome 和 firefox 网络驱动程序都不起作用.

I am unable know whats happening here, and why both chrome and firefox web drivers are not working.

推荐答案

its webdriver.Chrome() not webdriver.Chromedriver()

并且您可以通过将可执行文件的路径指定为参数来避免复制/usr/bin ..etc 中的可执行文件

and you can avoid copying the executable in /usr/bin ..etc by specifying the path to the executable as an argument

webdriver.Chrome(executable_path='...')

这样您就可以避免一个额外的步骤,并且还可以将驱动程序签入您的源代码控制目录等.

that way you can avoid one extra step and also have the driver checked into your source control directory etc.

这篇关于chromedriver 的 python-selenium 绑定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆