我有以下代码用Shutterbug捕获屏幕截图。但它会创建文件夹,并将屏幕截图存储在该文件夹中。有人可以帮助我确定问题吗?理想情况下,我想将所有屏幕截图保存在一个文件夹中。
public class CaptureScreenshot {
public static void Screenshot(WebDriver driver,String screenshotName) throws IOException {
SimpleDateFormat formatter = new SimpleDateFormat("dd-mm-yyyy-hhmmss");
Date date = new Date();
String screenshotNameFormat = screenshotName + " "+ formatter.format(date);
Shutterbug.shootPage(driver, ScrollStrategy.BOTH_DIRECTIONS,500,true).withName(screenshotNameFormat).save("./ScreenShots/"+screenshotNameFormat+".png");
}
}
答案 0 :(得分:1)
The github page on selenium-shutterbug表示def heatmap():
heatmap = "123"
return heatmap
def run():
heatmap = heatmap()
return heatmap
print(run())
仅会使用目录,而不是文件名:
save()
所以您的情况应该是
Shutterbug.shootPage(driver)
...
.withName("home_page")
...
.save("C:\\testing\\screenshots\\");