我已经写在Selenium/Java
下面的代码,以黄瓜截图,但我想参数化这个代码,并添加截图是采取该标签名称:如何使用标签名称
@Then("^Take Screenshot$")
public void tearDown() {
// take the screenshot at the end of every test
String location = "D:/ubdd/screenshots/";
DateFormat dateFormat = new SimpleDateFormat("dd-mm-yyyy h-m-s");
Date date = new Date();
File scrFile =
((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// now save the screenshto to a file some place
try {
FileUtils.copyFile(scrFile, new File(location +
dateFormat.format(date)+".png"));
System.out.println("Screenshot saved");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
欢迎来到StackOverflow!请查看[提问问题指南](https://stackoverflow.com/help/asking),特别是[如何创建最小,完整和可验证示例](https://stackoverflow.com/help/MCVE) – AesSedai101