2012-02-24 19 views
2

ChromeDriverで画像を読み込まないようにしようとしています。私は次のコードを使用していますが、まだイメージをロードしています。助言がありますか?Selenium ChromeDriverで画像を無効にする

DesiredCapabilities capabilities = DesiredCapabilities.Chrome(); 
capabilities.SetCapability("chrome.switches", new string[1] { "disable-images" }); 
IWebDriver driver = new ChromeDriver(@"C:\chromedriver\", capabilities); 
+0

Chromeコマンドラインスイッチのリストで「disable-images」が表示されません。私は簡単なgoogle検索で "--disable-images"という言葉を見ていますが、うまくいかないようです。 http://peter.sh/experiments/chromium-command-line-switches/ – Douglas

+0

いくつかの場所には言及があります。そのサイトを訪れましたが、それが包括的なリストであるかどうかは不明でした。 – stats101

答えて

2

私は同じ問題を抱えていましたが、回答はhereでした。

Map<String, Object> contentSettings = new HashMap<String, Object>(); 
contentSettings.put("images", 2); 

Map<String, Object> preferences = new HashMap<String, Object>(); 
preferences.put("profile.default_content_settings", contentSettings); 

DesiredCapabilities caps = DesiredCapabilities.chrome(); 
caps.setCapability("chrome.prefs", preferences); 
+2

これはクロームドライバにどのように追加されますか?作成する3つの変数はどうなりますか? –

関連する問題