Selenium firefox浏览器不能使用Python在centos 6.0上运行

时间:2013-03-11 13:07:47

标签: python selenium selenium-webdriver

如何让Selenium在Centos 6.0上运行?我得到以下错误。我在python 2.6上使用selenium 2.31.0

yum install ImageMagick ImageMagick-perl  xorg-x11-server-Xephyr Xvfb firefox
sudo yum -y install python-imaging
sudo easy_install pyvirtualdisplay
sudo easy_install selenium

from pyvirtualdisplay import Display
from selenium import webdriver
import time
import argparse
import os
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox()


Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib/python2.6/site-packages/selenium-2.31.0-py2.6.egg/selenium/webdriver/firefox/webdriver.py", line 58, in __init__
   self.binary, timeout),
 File "/usr/lib/python2.6/site-packages/selenium-2.31.0-py2.6.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
   self.binary.launch_browser(self.profile)
 File "/usr/lib/python2.6/site-packages/selenium-2.31.0-py2.6.egg/selenium/webdriver/firefox/firefox_binary.py", line 48, in launch_browser
   self._wait_until_connectable()
 File "/usr/lib/python2.6/site-packages/selenium-2.31.0-py2.6.egg/selenium/webdriver/firefox/firefox_binary.py", line 95, in _wait_until_connectable
   self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile Dir: /tmp/tmpUYQhu2 Firefox output: Xlib:  extension "RANDR" missing on display ":1170.0".
*** LOG addons.xpi: startup
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /home/efuadmin/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/.fedora-langpack-install
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi: No changes found'

1 个答案:

答案 0 :(得分:0)

对于python 2.7,硒的安装需要pip:

/usr/bin/python2.7 -m pip install --user selenium

针对您的python 2.6尝试一下。它可以在Red Hat 6和Centos 6上运行。

为避免在调用可执行文件时出现路径问题,您也可以使用此选项:

driver = webdriver.Firefox(executable_path='/bin/geckodriver')