首页 > 其他 > 详细

Capturing Screenshots

时间:2019-10-05 16:02:31      阅读:71      评论:0      收藏:0      [点我收藏+]

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

protected void takeScreenshot(String fileName) {
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String path = System.getProperty("user.dir") + "//test-output//screenshots//" + fileName + ".png";
try {
FileUtils.copyFile(scrFile, new File(path));
} catch (IOException e) {
e.printStackTrace();
}
}

 

Note: need apache commons io dependency

<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>

Capturing Screenshots

原文:https://www.cnblogs.com/amy2012/p/11624777.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!