2016-08-02 4 views
-3

セレンのクロムドライバオブジェクトのインスタンスに対して、複数の機能を設定しようとしています。 私はまずブラウザに ファイルのダウンロード場所を設定してから、Chromeブラウザでpdf viewerプラグインを無効にします。誰も助けることができますか? PDFビューアプラグインを無効にするセレンの複数の望ましい機能の設定

コードスニペット:ダウンロード場所を設定するための

DesiredCapabilities caps = DesiredCapabilities.chrome(); 
    Map<String, Object> preferences = new HashMap<String, Object>(); 
    preferences.put("plugins.plugins_disabled", new String[] { "Chrome PDF Viewer" }); 
    ChromeOptions options1 = new ChromeOptions(); 
    options1.setExperimentalOption("prefs", preferences); 
    caps.setCapability(ChromeOptions.CAPABILITY, options1); 

コードスニペット:

Map<String, Object> prefs = new HashMap<String, Object>(); 
    prefs.put("download.default_directory", "C:\\Users\\user\\Downloads\\"); 
    ChromeOptions options = new ChromeOptions(); 
    options.setExperimentalOption("prefs", prefs); 
    caps.setCapability(ChromeOptions.CAPABILITY, options); 
+2

あなたが尋ねていることは完全にはっきりしません。 [ask]をお読みください。あなたが英語に精通していない場合は、Google Translatorの使用を検討してください。 – xenteros

+0

私は、クロムドライバのインスタンスに対して複数の機能を設定しようとしています。私は、クロムブラウザのダウンロード場所を設定し、ブラウザインスタンスでPDFビューアを無効にしたいと思います。 –

+0

あなたが試したコードを投稿してください。 – tak3shi

答えて

0

あなたが複数の機能をしたいという理由だけで二つの別々のChromeOptionsを作成しないでください。だから彼らは地図を撮るのです。両方のキーの値のペアを1つのマップに入れてからオプションオブジェクトに追加してください。例:

DesiredCapabilities caps = DesiredCapabilities.chrome(); 
Map<String, Object> preferences = new HashMap<>(); 
preferences.put("plugins.plugins_disabled", new String[] { "Chrome PDF Viewer" }); 
preferences.put("download.default_directory", "C:\\Users\\user\\Downloads\\"); 
ChromeOptions options = new ChromeOptions(); 
options.setExperimentalOption("prefs", preferences); 
caps.setCapability(ChromeOptions.CAPABILITY, options); 
関連する問題