我已經寫在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