我想让Selenium在我的Dreamhost共享网络主机上的虚拟python环境中运行Firefox无头。
selenium驱动程序无法找到我的Firefox二进制文件,即使我已经在我的代码中指定了它的路径并将其添加到我的PATH中。
我将64位firefox 46.0.1 tar解压缩到〜/ bin / firefox。
我也跑了chmod 777 ~/bin/firefox/firefox
。
我没有sudo访问权限。
[SharedWebServer]$ cat ~/.bashrc
export PATH="$PATH:~/bin/firefox"
alias firefox="~/bin/firefox/firefox"
alias pythonactivate='source $HOME/<DOMAIN>/env/bin/activate'
[SharedWebServer]$ hash
hits command
0 /home/<user>/bin/firefox/firefox
[SharedWebServer]$ which firefox
[SharedWebServer]$
[SharedWebServer]$ export DISPLAY=:10
[SharedWebServer]$ export
declare -x DISPLAY=":10"
declare -x GEM_HOME="/home/<user>/.gems"
declare -x GEM_PATH="/home/<user>/.gems:/usr/lib/ruby/gems/1.8"
declare -x HOME="/home/<user>"
declare -x LC_COLLATE="C"
declare -x LOGNAME="<user>"
declare -x MAIL="/home/<user>/Maildir/"
declare -x OLDPWD
declare -x PATH="/home/<user>/.gems/bin:/usr/lib/ruby/gems/1.8/bin/:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
declare -x PS1="[\\h]\$ "
declare -x PWD="/home/<user>"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="<blah>"
declare -x SSH_CONNECTION="<blah>"
declare -x SSH_TTY="/dev/pts/1"
declare -x TERM="xterm"
declare -x USER="<user>"
firefox_binary = FirefoxBinary(firefox_path='/home/<user>/bin/firefox/firefox')
firefox_profile = custom_firefox_profile(images=False, css=True, flash=False)
driver=webdriver.Firefox(firefox_binary=firefox_binary,firefox_profile=firefox_profile)
vdisplay = Xvfb()
vdisplay.start()
&#34;请指定firefox二进制位置或安装firefox&#34;)
RuntimeError:无法在系统路径中找到firefox。请指定firefox二进制位置或安装firefox
[SharedWebServer]$ source $HOME/<DOMAIN>/env/bin/activate
(env)[SharedWebServer]$ python main.py
Traceback (most recent call last):
File "main.py", line 238, in <module>
sys.exit(main())
File "main.py", line 71, in main
driver=webdriver.Firefox(firefox_binary=firefox_binary,firefox_profile=firefox_profile)
File "/home/<user>/<domain>/env/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 67, in __init__
firefox_options.binary_location = self.binary if isinstance(self.binary, basestring) else self.binary._get_firefox_start_cmd()
File "/home/<user>/<domain>/env/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 163, in _get_firefox_start_cmd
" Please specify the firefox binary location or install firefox")
RuntimeError: Could not find firefox in your system PATH. Please specify the firefox binary location or install firefox