Print de tela (screenshot)

16 views
Skip to first unread message

Andre Damasceno Dias

unread,
Sep 26, 2013, 2:06:25 PM9/26/13
to seleniu...@googlegroups.com
A titulo de informação estou enviando aqui o código para print de tela

Com data e hora
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formater = new SimpleDateFormat("dd_MM_yyyy_hh_mm_ss");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("C:\\Java\\screenshot\\Nome_"+formater.format(calendar.getTime())+".png"));

Também da para passar o nome de uma variavel no arquivo

 Calendar calendar = Calendar.getInstance();
 SimpleDateFormat formater = new SimpleDateFormat("dd_MM_yyyy_hh_mm_ss");
 File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
 FileUtils.copyFile(scrFile, new File("C:\\Java\\screenshot\\Nome_"+variavel1+"_"+variavel2+"_"+variavel3+"_"+formater.format(calendar.getTime())+".png"));

Reply all
Reply to author
Forward
0 new messages