【问题标题】:Error in Selenium Python - Cannot create webdriverSelenium Python 中的错误 - 无法创建 webdriver
【发布时间】:2013-06-23 03:58:58
【问题描述】:

我正在使用 Selenium (Python) 创建 Web 驱动程序。几个小时前它工作正常。但是现在它给出了以下异常:

Traceback (most recent call last):
  File "/local/data2/mwaqar/opt/Python-2.7.4/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/local/data2/mwaqar/opt/Python-2.7.4/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/cshome/mwaqar/AEK/AEK_extract_community.py", line 49, in extract_community
    driver = webdriver.Firefox()
  File "/local/data2/mwaqar/opt/Virtual-Python-2.7.4/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 61, in __init__
    self.binary, timeout),
  File "/local/data2/mwaqar/opt/Virtual-Python-2.7.4/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/local/data2/mwaqar/opt/Virtual-Python-2.7.4/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 51, in launch_browser
    self._wait_until_connectable()
  File "/local/data2/mwaqar/opt/Virtual-Python-2.7.4/lib/python2.7/site-packages/selenium-2.33.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 95, in _wait_until_connectable
    self.profile.path, self._get_firefox_output()))
WebDriverException: Message: 'Can\'t load the profile. Profile Dir: /cshome/mwaqar/AEK/tmpgZ0n_J Firefox output: \n(Gecko:32421): Gtk-WARNING **: Unable to locate theme engine in module_path: "clearlooks",\n*** LOG addons.xpi: startup\n*** LOG addons.xpi: checkForChanges\n*** LOG addons.xpi: No changes found\n*** LOG addons.xpi: Add-ons list is invalid, rebuilding\n*** LOG addons.xpi-utils: Opening database\n'

我不知道是什么原因造成的。有人能指点一下吗?

更新:我使用的代码很简单

from pyvirtualdisplay import Display
from selenium import webdriver

display = Display(size=(800,600), visible=0)
display.start()

driver = webdriver.Firefox() # gives exception

【问题讨论】:

  • 尝试禁用/卸载 clearlooks 插件。我认为它伤害了我猜的网络驱动程序
  • 我什至不使用 Firefox。如果这是问题所在,那么几个小时前它是如何正常工作的?
  • 可能您应该粘贴代码以获得更好的答案。我假设您通过查看异常在 Firefox 上运行
  • 添加了代码。很简单。
  • 你的机器上没有安装firefox浏览器?

标签: python selenium python-2.7 selenium-webdriver


【解决方案1】:

我设法解决了这个问题。问题在于,由于我多次执行该脚本,因此许多 Firefox 用户配置文件(对应于 webdriver 实例)存在于/tmp//var/tmp/ 目录(名称为tmp*)中。一旦我删除了这些目录,问题就消失了。

【讨论】:

    猜你喜欢
    • 2017-04-11
    • 1970-01-01
    • 2022-06-11
    • 1970-01-01
    • 1970-01-01
    • 2019-01-21
    • 1970-01-01
    • 2016-09-15
    • 1970-01-01
    相关资源
    最近更新 更多