2014-04-02 33 views
3

當rdp會話關閉時,出現黑屏截圖常見問題。 沒有找到任何有關此問題的工作答案。 我有java-selenium測試。 代碼:在遠程計算機上使用robot.createScreenCapture獲取黑色圖像

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(); 
    } 
    } 

當我運行通過詹金斯遠程服務器(Windows Server 2008 R2)和RDP會話被關閉測試,我得到黑色的屏幕截圖。 如果會話是活動的 - 我得到正常的截圖。 但是,當會話關閉時,我需要製作正常的屏幕截圖。

我該怎麼做? 有什麼建議嗎?

VisualCron和selenium.captureScreenshot()不適合我。

+0

同樣的問題在這裏。在Win 2003上,你可以/ console登錄和'tscon 0/dest:console'來斷開連接。使用VNC是一種解決方案,但我寧願不要。 – Dormouse

回答

0

我一直在尋找使用VNC服務器的替代方案,但找不到它。所以我的答案是「使用VNC」。我個人更喜歡UltraVNC

安裝時,使用uvnc會話啓動您的硒Jenkins從屬並斷開連接。

AWT機器人將現在工作。

相關問題