@BeforeMethod
private void openBrowser()
private void openBrowser()
{
try
try
{
FirefoxProfile fxProfile = new FirefoxProfile();
fxProfile.setPreference("browser.download.folderList",2);
fxProfile.setPreference("browser.download.manager.showWhenStarting",false);
fxProfile.setPreference("browser.download.dir","/home/chinna/Desktop/Locust/pdf"); // ADD YOUR DOWNLOAD PATH
fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/pdf");
fxProfile.setPreference("browser.download.manager.showWhenStarting", false);
fxProfile.setPreference("browser.download.manager.focusWhenStarting", false);
fxProfile.setPreference("browser.helperApps.alwaysAsk.force", false);
fxProfile.setPreference("browser.download.manager.alertOnEXEOpen", false);
fxProfile.setPreference("browser.download.manager.closeWhenDone", false);
fxProfile.setPreference("browser.download.manager.showAlertOnComplete", false);
fxProfile.setPreference("browser.download.manager.useWindow", false);
fxProfile.setPreference("browser.download.manager.showWhenStarting",false);
fxProfile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
fxProfile.setPreference( "pdfjs.disabled", true );
driver = new FirefoxDriver(fxProfile);
driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://seleniumsubbu.blogspot.in/");
Thread.sleep(2000);
waitForTitleToPresent("Selenium 2+ Experiance | TechLearn");
}catch(Throwable t)
FirefoxProfile fxProfile = new FirefoxProfile();
fxProfile.setPreference("browser.download.folderList",2);
fxProfile.setPreference("browser.download.manager.showWhenStarting",false);
fxProfile.setPreference("browser.download.dir","/home/chinna/Desktop/Locust/pdf"); // ADD YOUR DOWNLOAD PATH
fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/pdf");
fxProfile.setPreference("browser.download.manager.showWhenStarting", false);
fxProfile.setPreference("browser.download.manager.focusWhenStarting", false);
fxProfile.setPreference("browser.helperApps.alwaysAsk.force", false);
fxProfile.setPreference("browser.download.manager.alertOnEXEOpen", false);
fxProfile.setPreference("browser.download.manager.closeWhenDone", false);
fxProfile.setPreference("browser.download.manager.showAlertOnComplete", false);
fxProfile.setPreference("browser.download.manager.useWindow", false);
fxProfile.setPreference("browser.download.manager.showWhenStarting",false);
fxProfile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
fxProfile.setPreference( "pdfjs.disabled", true );
driver = new FirefoxDriver(fxProfile);
driver.manage().timeouts().implicitlyWait(15,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("http://seleniumsubbu.blogspot.in/");
Thread.sleep(2000);
waitForTitleToPresent("Selenium 2+ Experiance | TechLearn");
}catch(Throwable t)
{
System.err.println("There is an issue in launching the application ,please check "+t);
}
System.err.println("There is an issue in launching the application ,please check "+t);
}
}
private void waitForTitleToPresent(String locator)
private void waitForTitleToPresent(String locator)
{
WebDriverWait wait=new WebDriverWait(driver,15);
wait.until(ExpectedConditions.titleIs(locator));
}
@Test
public void PDFDOWNLOAD() throws InterruptedException
WebDriverWait wait=new WebDriverWait(driver,15);
wait.until(ExpectedConditions.titleIs(locator));
}
@Test
public void PDFDOWNLOAD() throws InterruptedException
{
Thread.sleep(1000);
driver.switchTo().frame(driver.findElement(By.className("pdf")));
driver.findElement(By.id("download")).click();
Thread.sleep(5000);
Thread.sleep(1000);
driver.switchTo().frame(driver.findElement(By.className("pdf")));
driver.findElement(By.id("download")).click();
Thread.sleep(5000);
}