gpt4 book ai didi

java - 问题: Shutterbug Screenshot create a new folder for each screenshot instead of keeping them in 1 folder

转载 作者:行者123 更新时间:2023-12-02 01:44:55 27 4
gpt4 key购买 nike

enter image description here

我有下面的代码来使用 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");
}
}

最佳答案

The github page on selenium-shutterbug表示 save() 只会获取目录,而不是文件名:

 Shutterbug.shootPage(driver)
...
.withName("home_page")
...
.save("C:\\testing\\screenshots\\");

所以在你的情况下应该是

Shutterbug.shootPage(driver, ScrollStrategy.BOTH_DIRECTIONS,500,true).withName(screenshotNameFormat).save("./ScreenShots/");

关于java - 问题: Shutterbug Screenshot create a new folder for each screenshot instead of keeping them in 1 folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53835171/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com