I am using Java and selenium to write some tests. I need to record my screenshot while the tests are running it makes much easier for me to track if any bugs occurs. The problem is that I need to run more than one tests at the same time and as I have only one monitor I cannot record all of their screenshots at the same time so I have to run the test one after each other. I was wondering if there is any way that I can run all my tests and actually minimize their browsers windows but still record what is going on at each minimized chrome window. My question may sound a bit very strange but that makes my testing very faster.
1 Answer
Yes, definitely we can take multiple screenshots. There is no affect whether the browser is in minimize or Maximize condition. Just you have to switch the new opened window & add "Take screenshot" method after each method where you have to take screenshot.
Take screenshot method can work in both mode while browser is either in Minimize or Maximize condition.
Use below Take screentShot method code for taking multiple screenshots within a class:
public void screenShot() throws IOException, InterruptedException {
File scr = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String filename = new SimpleDateFormat("yyyyMMddhhmmss'.txt'").format(new Date());
File dest = new File("filePath/" + filename);
FileUtils.copyFile(scr, dest);
}