Following code is perfectly downloading the PDF. Now I want to convert this PDF content to Text file.Please help. I tried with a lot many codes by goggling but none of them worked.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@Test
public class PDF_Download_without_popup {
WebDriver driver;
@BeforeTest
public void StartBrowser() {
//Create object of FirefoxProfile in built class to access Its properties.
FirefoxProfile fprofile = new FirefoxProfile();
//Set Location to store files after downloading.
fprofile.setPreference("browser.download.dir", "c:\\WebDriverdownloads");
fprofile.setPreference("browser.download.folderList", 2);
//Set Preference to not show file download confirmation dialogue using MIME types Of different file extension types.
fprofile.setPreference("browser.helperApps.neverAsk.saveToDisk",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;"//MIME types Of MS Excel File.
+ "application/pdf;" //MIME types Of PDF File.
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document;" //MIME types Of MS doc File.
+ "text/plain;" //MIME types Of text File.
+ "text/csv"); //MIME types Of CSV File.
fprofile.setPreference( "browser.download.manager.showWhenStarting", false );
fprofile.setPreference( "pdfjs.disabled", true );
//Pass fprofile parameter In webdriver to use preferences to download file.
driver = new FirefoxDriver(fprofile);
}
public void OpenURL() throws InterruptedException{
driver.get("http://www.bell.ca/");
driver.manage().window().maximize();
Thread.sleep(30000);
driver.findElement(By.xpath(".//*[@id='demoLoginLinkJs']/span[1]")).click();
driver.findElement(By.xpath(".//*[@id='USER']")).sendKeys("bell_56789");
driver.findElement(By.xpath(".//*[@id='PASSWORD']")).sendKeys("sunday21");
driver.findElement(By.xpath(".//*[@id='demoLoginJs']")).click();
driver.findElement(By.xpath("//span[contains(text(),'View current bill')]")).click();
Thread.sleep(5000);
driver.findElement(By.xpath(".//*[@id='btnDownloadBill']")).click();
String tmp= driver.getCurrentUrl().toString();
System.out.println(tmp);
Thread.sleep(50000);
}
@AfterTest
public void CloseBrowser() {
driver.quit();
}
}