0

While running selenium scripts, I need to capture the complete screen in my application. Initially I used, TakesScreenshot interface in Selenium, but that didn't capture the complete screen. I googled and I found this.

    Robot robot = new Robot();
    BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
    ImageIO.write(screenShot, "JPG", new File("ScreenShot.jpg"));

This works just fine except the fact that while executing the scripts, you cannot navigate to any screen other than the ones you need to capture. Essentially this does the function of Print Screen button. This negates the purpose of automation. I need to know if there is any other method to capture complete screen(including URL) without having to stay in the screen you want to capture.

Community
  • 1
  • 1
justcurious
  • 839
  • 3
  • 12
  • 29
  • Please provide the code that you have used that didn't work. – JeffC Aug 27 '15 at 18:43
  • You can find that in the link I provided. Anyhow, i have edited and added the code in my question, now. – justcurious Aug 28 '15 at 06:57
  • so you want to take a screenshot of the whole browser-window including tabs & url and everything? Without the need to have this window in the foreground, because for example you are writing something in a word processor and your tests run in the background? Did I understand you correctly? – drkthng Aug 28 '15 at 07:28
  • Exactly, that is what I meant. Btw, why your answer was deleted? – justcurious Aug 28 '15 at 09:00

0 Answers0