// ساعت فعلی را دریافت کنید LocalDateTime currentTime = LocalDateTime.now(); // تبدیل ساعت فعلی به فرمت مورد نظر (برای مثال: yyyy-MM-dd_HH-mm-ss) DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss"); String formattedTime = currentTime.format(formatter); // تولید نام فایل با استفاده از ساعت فعلی String fileName = "screenshot_" + formattedTime + ".png"; // ایجاد فایل اسکرینشات File screenshotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); // ذخیره اسکرینشات با نام مورد نظر try { FileUtils.copyFile(screenshotFile, new File("path/to/HamrahCard/" + fileName)); System.out.println("Screenshot saved successfully."); LOGGER.info("Screenshot saved successfully: path/to/HamrahCard/" + fileName); } catch (IOException e) { System.out.println("Failed to save screenshot: " + e.getMessage()); }