Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.firefox.FirefoxProfile;
- public class FileDownloadFFsetPreference {
- public static void main(String[] args) {
- FirefoxProfile myTestProfile = new FirefoxProfile();
- myTestProfile.setPreference("browser.download.folderList", 2);
- myTestProfile.setPreference("browser.download.dir","C:\\Test");
- myTestProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
- "application/x-jar,application/application/vnd.android.package-archive,application/msword,application/x-rar-compressed,application/octet-stream,application/csv,text/csv");
- WebDriver myTestDriver = new FirefoxDriver(myTestProfile);
- myTestDriver.get("http://onlineseleniumtraining.com/downloads/");
- myTestDriver.findElement(By.xpath("//*[@id='downloads']/a")).click();
- myTestDriver.findElement(By.xpath("//*[@id='downloads']/p[2]/a")).click();
- myTestDriver.findElement(By.xpath("//*[@id='downloads']/p[3]/a")).click();
- myTestDriver.findElement(By.xpath("//*[@id='downloads']/p[4]/a")).click();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement