Scenario: after click on PDF buttton > new window open with document.
Issue: when i used getTitle , its returned the previous page title
Question : is it because the PDF page opens its not normal page and PDF page?
Please help me out here
Code:
invoicePDFButton.click();
Thread.sleep(7000);
String windowTitle = driver.getTitle();
System.out.println(windowTitle);
if(!windowTitle.equals("servlet.FileDownload"))
{
System.out.println("Invoice PDF failed to open");
Assert.fail();
}
else
{
System.out.println("Invoice PDF open successfully.");
}
driver
will be referring to the first tab, not the new one with your PDF. You need to change that.