2017-09-29 5 views
-1

私は質問を編集しました。セレン3.6.0と拡張子

セレンのpythonバインディングを使ってfirefoxのゴーストの拡張機能をブロックする方法を教えてください。デフォルトでは、ゴースのブロックは無効になっています。 セレン3.6.0とゴースト7.3.3.7を使用しています。リリースされたバージョンにはこの機能がないため、新しいWeb拡張機能を使用できるselenium + pull request#4790を使用しています。

I次の操作を行います。

from selenium import webdriver 
fp = webdriver.FirefoxProfile() 
fp.add_extension(extension=/home/nsarafij/ghostery-7.3.3.7.xpi) 
driver = webdriver.Firefox(firefox_profile = fp) 

それは環境設定によってghosteryブロッキング活性化させることは可能ですか?

fp.set_preferances(...)私は別の何かをしなければならない

か、?

答えて

0

私はあなたを正しく理解していません - FirefoxにGhosteryを正しく追加したいですか?

もしそうなら、これは動作するはずです:

from selenium import webdriver 
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile 
firefoxProfile = FirefoxProfile() 
ghostery="PATH_TO_GHOSTERY_ADDON" 
firefoxProfile.add_extension(ghostery) 
firefoxProfile.update_preferences() 
driver = webdriver.Firefox(firefoxProfile)