【发布时间】:2014-04-02 07:32:06
【问题描述】:
当 rdp 会话关闭时,我遇到了一个常见的问题。 没有找到此问题的任何有效答案。 我有 java-selenium 测试。 代码:
private void screenShot() {
try {
String newFileNamePath;
File directory = new File (".");
DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
Date date = new Date();
newFileNamePath = directory.getCanonicalPath() + "\\test-output\\" + "logs\\" + "screenshot_" + dateFormat.format(date) + ".png";
System.out.println(newFileNamePath);
//Capture the screen shot of the area of the screen defined by the rectangle
Robot robot = new Robot();
BufferedImage bi=robot.createScreenCapture(new Rectangle(1920,1080));
ImageIO.write(bi, "png", new File(newFileNamePath));
Reporter.log(newFileNamePath);
}
catch (AWTException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
当我通过 Jenkins 在远程服务器 (Windows Server 2008 R2) 上运行测试并且 rdp-session 关闭时,我得到黑色屏幕截图。 如果会话处于活动状态 - 我会得到正常的屏幕截图。 但是我需要在会话关闭时制作正常的屏幕截图。
我怎样才能做到? 有任何想法吗?
VisualCron 和 selenium.captureScreenshot() 不适合我。
【问题讨论】:
-
这里有同样的问题。在 Win 2003 上,您可以 /console login 和
tscon 0 /dest:console断开连接。使用 VNC 是一种解决方案,但我不想这样做。
标签: windows session selenium remote-desktop rdp