2016-12-18 10 views
4

注意を働いていないXvfbのとセレンヘッドレス・テスト私はすでに次のソースを見てきました:私の問題を解決していなかったのPython 2.7から

easyprocess.EasyProcessCheckInstalledError: cmd=['Xvfb', '-help'] OSError=[Errno 2] No such file or directory

How do I run Selenium in Xvfb?

私が使用しています:

  • のPython 2.7
  • セレン3.0.2
  • xvfbwrapper 0.2.9
  • PyVirtualDisplay 0.2.1

をマックOSXエルキャピタン上で実行します( 10.11.6(15G1108))

私はフォール

Traceback (most recent call last): 
    File "/Users/user/Desktop/test.py", line 50, in <module> 
    display = Display(visible=0, size=(800, 600)) 
    File "/Library/Python/2.7/site-packages/pyvirtualdisplay/display.py", line 34, in __init__ 
    self._obj = self.display_class(
    File "/Library/Python/2.7/site-packages/pyvirtualdisplay/display.py", line 52, in display_class 
    cls.check_installed() 
    File "/Library/Python/2.7/site-packages/pyvirtualdisplay/xvfb.py", line 38, in check_installed 
    ubuntu_package=PACKAGE).check_installed() 
    File "/Library/Python/2.7/site-packages/easyprocess/__init__.py", line 180, in check_installed 
    raise EasyProcessCheckInstalledError(self) 
EasyProcessCheckInstalledError: cmd=['Xvfb', '-help'] 
OSError=[Errno 2] No such file or directory 
Program install error! 

私はXvfbのが同様にインストールされている知っている:

Xvfb -help 
use: X [:<display>] [option] 
-a #     default pointer acceleration (factor) 
-ac     disable access control restrictions 
-audit int    set audit trail level 
-auth file    select authorization file 
-br     create root window with black background 
+bs     enable any backing store support 
-bs     disable any backing store support 
-c      turns off key-click 
... 
-pixdepths list-of-int support given pixmap depths 
+/-render   turn on/off RENDER extension support(default on) 
-linebias n   adjust thin line pixelization 
-blackpixel n   pixel value for black 
-whitepixel n   pixel value for white 
-fbdir directory  put framebuffers in mmap'ed files in directory 
-shmem     put framebuffers in shared memory 

ピップインストールは異なるにXVFBを探している場合(上記のリンクにあるものと同じである)エラーをためディレクトリには、見た目のどこにリダイレクトするかについてのいくつかの指針があります。 、私がインストールされ、検索をGoogleと何もこれまでのところ、究極の最終目標は、ダウンロードを処理することが可能であるヘッドレス自動化を持っている役立っていない無数のピップを行ってきた

from easyprocess import EasyProcess 
from pyvirtualdisplay import Display 
from selenium import webdriver 

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

# now Firefox will run in a virtual display. 
# you will not see the browser. 
browser = webdriver.Firefox() 
browser.get('http://www.google.com') 
print browser.title 
browser.quit() 

display.stop() 

は、ここに私のコードですPhantomJSができないもの。その主題の中のどんな助けも高く評価されるでしょう。

+0

これはosxで使用できません –

+0

@CoreyGoldberg何が使えますか?私はcasperjsに亡命しましたが、もし私がPythonを使いたいのであれば、どうすればOSX上でそれを実行できますか? –

+0

Chromeはバージョン59以上のヘッドレス版をリリースしました。これをチェックすることができます。 – demouser123

答えて

2

私はなぜこれをosxで使用できないのか分かりませんが、私はそれを過去に行っています。しかし、私はより良い解決策を持っています。なぜ使用しないでくださいdocker + VNC。任意のブラウザをインストールし、すべてをバックグラウンドで実行してください。 利点: 1.すべてがバックグラウンドで実行されます。 2. VNC Webビューのブラウザでの実行のモニタ 3.並列実行に必要な数のコンテナを起動します。