标签:output screens ring end util tst enc com out
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>
标签:output screens ring end util tst enc com out
原文地址:https://www.cnblogs.com/amy2012/p/11624777.html