2017-06-25 6 views
1

私はPython 2.7.12をSeleniumバージョン2.53.6とfirefox 46.0.1で実行しています。私の目標は、AWS Ubuntu Server 16.04 LTSでヘッドレステストを実行することです。これは私がそれを設定した方法です。 echo export 'PATH="$PATH:/home/ubuntu/firefox"' >> ~/.bashrcを実行して、Firefoxドライバーを使用してUbuntu LTSでHeadless Webdriverテストを実行しています

Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 55, in __init__ 
self.binary = firefox_binary or capabilities.get("binary", FirefoxBinary()) 
File "/home/ubuntu/anaconda2/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 47, in __init__ 
self._start_cmd = self._get_firefox_start_cmd() 
File "/home/ubuntu/anaconda2/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 

私はbashのプロファイルでFirefoxのへのリンクを追加しようとしましたが、その:私はこのコードを実行すると

# install anaconda 
cd ~ 
wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh 
bash Anaconda2-4.2.0-Linux-x86_64.sh 
rm Anaconda2-4.2.0-Linux-x86_64.sh 
echo export 'PATH="/home/ubuntu/anaconda2/bin:$PATH"' >> ~/.bashrc 
source .bashrc 
conda update conda 

# install firefox version 46.0.1 
wget https://ftp.mozilla.org/pub/firefox/releases/46.0.1/linux-x86_64/en-US/firefox-46.0.1.tar.bz2 
tar jxf firefox-46.0.1.tar.bz2 
rm firefox-46.0.1.tar.bz2 

# install pyvirtualdisplay 
sudo apt-get install xvfb xserver-xephyr 
pip install pyvirtualdisplay 

# install selenium version 2.53.6 
pip install selenium==2.53.6 

from pyvirtualdisplay import Display 
from selenium import webdriver 

display = Display(visible=0, size=(1024, 768)) 
display.start() 

browser = webdriver.Firefox() 
driver.get("http://www.python.org") 

driver.quit() 
display.stop() 

は、私はこのエラーを取得します問題を解決しなかった。

UPDATE

私は正常に私のbashプロファイルへのパスを追加することができました。私は今、私はすでにpyvirtualdisplayを使用していたことを、誰もが解決策を知っているん考えると、このエラー

"The browser appears to have exited " 
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details. 

を取得していますか?

答えて

0

私の理解しているように、Firefoxはヘッドレスメカニズム用にビルドされていません[私が間違っている場合は修正してください]。 を使用すると、操作性を向上させることができます。

関連する問題