0

I am using selenium web driver to automate my web application. I am using java.awt.robot class to take screenshots. When i run my test it will open the browser and it will perform as i need and it will take the screenshot of the front window on the desktop screen.

Actual need:

I minimized the screen of browser window which is opened by selenium and doing some other action in some application. In that case my test case will execute perfectly but the screenshot is not the browser window it is the application which i opened.

My need is to take the screenshot of the browser window when it was minimized too.

Is it possible to do using Robot? I am not saying I need screenshot by using robot class alone. Please suggest me other ways too.

Please consider I need the screenshot with out using TakesScreenshot class of selenium API.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Manigandan
  • 5,004
  • 1
  • 28
  • 47

2 Answers2

1

As far as I know, we won't be able to use Robot class to take snapshot of Browser window if we are upto something else on the screen. It's to capture whatever happening on your PC screen which is currently active there. Thanks

Deepu
  • 113
  • 2
  • 16
  • @Deepu: Thanks for the response. Is there any possible to achieve the above scenario other than the Robot? – Manigandan Jan 30 '13 at 07:09
  • 1
    @Manigandan : We're using Selenium's class in Selenium itself for taking screenshot. Can You pls specify why you want to use some other way? – Deepu Jan 30 '13 at 07:21
  • @Deepu: If we take screenshot using `TakesScreenshot` class for IE mean it will re-sizing the window to take screenshot. I don't want that thing to happen. For the reason i am preferring another way. – Manigandan Jan 30 '13 at 07:29
  • @Manigandan : Okay :) Sorry I'm not aware of any other way to do it other than those 2 :( – Deepu Jan 30 '13 at 07:35
0

Try this:

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
    try {
        FileUtils.copyFile(scrFile, new      File(System.getProperty("user.dir")+"\\screenshots\\"+fileName+".jpg"));
    } catch (IOException e) {
        e.printStackTrace();
    }      

Manigandan
  • 5,004
  • 1
  • 28
  • 47
Ram
  • 161
  • 2
  • 2
  • 10
  • Please read the post i need to take screenshot with out using the `TakeScreenshot` API. Provide answer relevant to the question. – Manigandan Feb 22 '13 at 12:08