3

Centos 6.0 で Selenium を動作させるにはどうすればよいですか? 以下のエラーが表示されます。Python 2.6でセレン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'
4

1 に答える 1

0

Python 2.7 の場合、Selenium には 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')
于 2020-03-06T23:56:52.650 に答える