2016-07-21 6 views
0

Firefoxでテストを実行するためのプロファイルを設定した後、ダウンロードポップアップをfalseに設定しましたが、テストを実行しても表示されます。Seleniumのプロファイル設定後にFirefoxのダウンロードポップアップが残る

 switch (browser){ 
     case "FFX": 
      System.out.println("Starting test in FireFox"); 
      try { 
       driver = new FirefoxDriver(firefoxProfile()); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
      //TODO Create a system properties file in case driver location moves. 
      break; 

    ... 
    public static FirefoxProfile firefoxProfile() throws Exception { 

    FirefoxProfile firefoxProfile = new FirefoxProfile(); 
    firefoxProfile.setPreference("browser.download.manager.showAlertOnComplete", false);   
    firefoxProfile.setPreference("browser.download.manager.alertOnEXEOpen", false); 
    firefoxProfile.setPreference("browser.download.manager.focusWhenStarting", false); 
    firefoxProfile.setPreference("browser.download.manager.useWindow", false); 
    firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false); 
    firefoxProfile.setPreference("browser.download.manager.closeWhenDone", false); 
    firefoxProfile.setPreference("browser.download.animateNotifications", false); 
    firefoxProfile.setPreference("browser.download.folderList", 2);  
    firefoxProfile.setPreference("browser.download.dir", downloadPath); 
    firefoxProfile.setPreference("browser.helperApps.alwaysAsk.force", false); 
    firefoxProfile.setPreference("browser.helperApps.neverAsk.openFile", 
      "text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/" 
      + "png,image/jpeg,text/html,text/plain,application/msword,application/xml"); 
    firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", 
      "text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/" 
      + "png,image/jpeg,text/html,text/plain,application/msword,application/xml"); 
    // ProfilesIni profile = new ProfilesIni(); 
    // firefoxProfile = profile.getProfile("selenium"); 

    return firefoxProfile; 

しかし、私はまだこのウィンドウを取得しています:

test

私は私のプロファイル設定のためのエントリーをしないのですがここで私が設定していたプロファイルはありますか?私はそれが可能だろうと思った:

firefoxProfile.setPreference("browser.download.manager.showAlertOnComplete", false); 

編集:私は、私は私のドライバを設定していますし、どのように私は私のプロフィールを構築していますどのように、これまでより多くを追加しました。私はまた、単にプロファイル「セレン」をドライバに割り当てるだけで、コメントアウトされた部分を追加しました。現在、何が起きているかは、ドライバーが起動したばかりで、まるで新鮮なインストールを毎回実行したかのようです。 setPreferences(またはそのほとんどすべて)に準拠していて、事前に設定したカスタムプロファイルは完全に無視されます。進行中のダウンロード確認通知は実際に私のテストをここで殺しています。どんなアイディアや観察も大変ありがとうございます。

答えて

0

セレンコードを実行したら、FirefoxのURLバーに「about:config」と入力して、設定が正しく設定されているかどうかを手動で確認できます。また、about:configページのをbrowser.download.animateNotificationsに変更してみてください。それが役に立てば幸い。

+0

私はこれを試して、うまくいきませんでした。私は恐れています。私はちょうどカスタムプロファイルを使用したいと思いますが、Firefoxは私のカスタムプロファイルを無視して、何らかの理由でデフォルトのプロファイルを使用しているようです。そうすれば、この全体がとても簡単になります。 –

+0

FireFoxプロファイル(testProfile)を手動で作成し、そのプロファイルを使用してドライバを起動してみてください。 'ProfilesIni profile =新しいProfilesIni(); FirefoxProfile myprofile = profile.getProfile( "testProfile"); WebDriverドライバ=新しいFirefoxDriver(myprofile); '[CustomFFProfile](http://toolsqa.com/selenium-webdriver/custom-firefox-profile/)リンクを参照できます。 – Harish

+0

私はすでにこれをやったと信じています(貼り付けたコードの最後の2行を見てください)。私が間違っていない限り。私はセレンに特有のものを作成し、それを使用しようとしましたが、ドライバはそれを無視しているようです。これは、「すぐに使用できる」または「デフォルト」の設定のみを使用します。 –

関連する問題