我在IE中有一个按钮,当点击按钮时,它会打开一个包含pdf文件的新窗口。
使用IE webdriver时,新窗口中未加载pdf,新窗口为空白且没有任何内容。 它适用于Chrome驱动程序,也适用于IE 新窗口也没有被硒检测到
使用IE驱动程序,我们对PDF查看有任何限制吗?
html代码
<INPUT class="ui-button ui-widget ui-state-default ui-corner-all"
id=previewLetter role=button aria-disabled=false style="WIDTH: 150px"
onclick="Javascript:ns_7_P8LL6OA610SGF0ADUCO96E3004_launchXpressions
('postform','preview_letter','/zawps/CR')" type=button
value="Preview Letter" jQuery15108424594360553599="13">
<FRAMESET rows=100%><FRAME
src="/wps/PA_onCR/LetterPreViewServlet?
NAVIGATION_PARAMETER=preview_letter&lettername=Billing
Notice&docId=383437&loginId=XXXX&version=16.0"></FRAMESET>
我正在尝试使用以下代码
String parentHandle = DriverFactory.getDriver().getWindowHandle(); // get the current window handle
Set<String> winHandles = DriverFactory.getDriver().getWindowHandles();
int numberOfWindows = winHandles.size();
DriverFactory.getDriver().findElement(By.xpath("//input[@value='Preview Letter']")).click();
System.out.println("2 : number of windows are" + winHandles.size());
System.out.println("2 : the title of page is" + DriverFactory.getDriver().getTitle());
System.out.println("2 : the title of page is" + DriverFactory.getDriver().getCurrentUrl());
for (String winHandle : DriverFactory.getDriver().getWindowHandles()) {
DriverFactory.getDriver().switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
System.out.println("3 : number of windows are" + winHandles.size());
System.out.println("3 : the title of page is" + DriverFactory.getDriver().getTitle());
System.out.println("3 : the title of page is" + DriverFactory.getDriver().getCurrentUrl());
//code to do something on new window
DriverFactory.getDriver().close(); // close newly opened window when done with it
DriverFactory.getDriver().switchTo().window(parentHandle); // switch back to the original window