使用 selenium - java 在 var/tmp 中创建带有屏幕截图 [SomeRandomnumber.png] 的文件名
Filename with screenshot[SomeRandomnumber.png] is created inside var/tmp while using selenium - java
我正在使用以下方法在我的 selenium 项目中截图
public String getScreenShotUrl(String fileName, Information information) {
final String screenShotS3FolderName = "/test/s3"
final String apiHistoryScreenshotUrl = "/test/history"
new Thread(() -> {
File screenshot = ((TakesScreenshot) information.getDriver()).getScreenshotAs(OutputType.FILE);
contentHandler.moveScreenshotImageFileToS3(fileName, screenShotS3FolderName, screenshot);
}).start();
String crawlScreenshotUrl = apiHistoryScreenshotUrl + fileName + DOT_JPEG_FILE_EXTENSION;
information.getAllScreenShotUrls().add(screenshotUrl);
return crawlScreenshotUrl;
}
我没有在任何地方存储文件 var/tmp foler
我使用的是 firefox 83
geco 驱动程序:28
os : linux
问题:
我看到里面有很多 png 文件
/var/tmp
screenshot18218906458183251330.png
现在确定是什么触发了我 firefox/selenium 中的屏幕截图。
这正在填满我的硬盘。我如何阻止 firefox 截取此屏幕截图。
不确定是哪个命令触发了这个。我最近升级到 firefox-83 但不确定 83 是这个问题的原因
根据 Rahul 命令,我明确地添加了删除命令。这解决了问题
添加 screenshot.delete() // 显式删除文件而不等待 jvm 退出
public String getScreenShotUrl(String fileName, Information information) {
final String screenShotS3FolderName = "/test/s3"
final String apiHistoryScreenshotUrl = "/test/history"
new Thread(() -> {
File screenshot = ((TakesScreenshot) information.getDriver()).getScreenshotAs(OutputType.FILE);
contentHandler.moveScreenshotImageFileToS3(fileName, screenShotS3FolderName, screenshot);
screenshot.delete() // This delete the file once it is moved to s3
}).start();
String crawlScreenshotUrl = apiHistoryScreenshotUrl + fileName + DOT_JPEG_FILE_EXTENSION;
information.getAllScreenShotUrls().add(screenshotUrl);
return crawlScreenshotUrl;
}
我正在使用以下方法在我的 selenium 项目中截图
public String getScreenShotUrl(String fileName, Information information) {
final String screenShotS3FolderName = "/test/s3"
final String apiHistoryScreenshotUrl = "/test/history"
new Thread(() -> {
File screenshot = ((TakesScreenshot) information.getDriver()).getScreenshotAs(OutputType.FILE);
contentHandler.moveScreenshotImageFileToS3(fileName, screenShotS3FolderName, screenshot);
}).start();
String crawlScreenshotUrl = apiHistoryScreenshotUrl + fileName + DOT_JPEG_FILE_EXTENSION;
information.getAllScreenShotUrls().add(screenshotUrl);
return crawlScreenshotUrl;
}
我没有在任何地方存储文件 var/tmp foler
我使用的是 firefox 83
geco 驱动程序:28
os : linux
问题:
我看到里面有很多 png 文件
/var/tmp
screenshot18218906458183251330.png
现在确定是什么触发了我 firefox/selenium 中的屏幕截图。
这正在填满我的硬盘。我如何阻止 firefox 截取此屏幕截图。
不确定是哪个命令触发了这个。我最近升级到 firefox-83 但不确定 83 是这个问题的原因
根据 Rahul 命令,我明确地添加了删除命令。这解决了问题 添加 screenshot.delete() // 显式删除文件而不等待 jvm 退出
public String getScreenShotUrl(String fileName, Information information) {
final String screenShotS3FolderName = "/test/s3"
final String apiHistoryScreenshotUrl = "/test/history"
new Thread(() -> {
File screenshot = ((TakesScreenshot) information.getDriver()).getScreenshotAs(OutputType.FILE);
contentHandler.moveScreenshotImageFileToS3(fileName, screenShotS3FolderName, screenshot);
screenshot.delete() // This delete the file once it is moved to s3
}).start();
String crawlScreenshotUrl = apiHistoryScreenshotUrl + fileName + DOT_JPEG_FILE_EXTENSION;
information.getAllScreenShotUrls().add(screenshotUrl);
return crawlScreenshotUrl;
}