我正在尝试捕获弹出窗口的屏幕但没有成功。
我将此代码用于“常规”捕获屏幕:
File scrFile = ((TakesScreenshot)alertDialog).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
当弹出窗口出现时,我想捕获弹出屏幕,我该怎么做?
public void checkPopup() throws IOException
{
Alert alertDialog = driver.switchTo().alert();
File scrFile = ((TakesScreenshot)alertDialog).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
String alertText = alertDialog.getText();
}