Advertisement
SeleniumETrainR

How to set firefox Preferences to work File types and downlo

Dec 18th, 2012
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import org.openqa.selenium.By;
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.firefox.FirefoxDriver;
  4. import org.openqa.selenium.firefox.FirefoxProfile;
  5.  
  6.  
  7. public class FileDownloadFFsetPreference {
  8.     public static void main(String[] args) {
  9.         FirefoxProfile myTestProfile = new FirefoxProfile();
  10.  
  11.         myTestProfile.setPreference("browser.download.folderList", 2);    
  12.  
  13.         myTestProfile.setPreference("browser.download.dir","C:\\Test");
  14.         myTestProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
  15.                 "application/x-jar,application/application/vnd.android.package-archive,application/msword,application/x-rar-compressed,application/octet-stream,application/csv,text/csv");
  16.         WebDriver myTestDriver = new FirefoxDriver(myTestProfile);
  17.         myTestDriver.get("http://onlineseleniumtraining.com/downloads/");
  18.         myTestDriver.findElement(By.xpath("//*[@id='downloads']/a")).click();
  19.         myTestDriver.findElement(By.xpath("//*[@id='downloads']/p[2]/a")).click();
  20.  
  21.         myTestDriver.findElement(By.xpath("//*[@id='downloads']/p[3]/a")).click();
  22.         myTestDriver.findElement(By.xpath("//*[@id='downloads']/p[4]/a")).click();
  23.  
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement