ScreenshotHelper
Playwright\Screenshot\ScreenshotHelper
Utility for generating screenshot filenames and managing screenshot directories.
Methods
generateFilename()
stringGenerate an auto screenshot filename based on current datetime and URL. Format: YYYYMMDD_HHMMSS_mmm_url-slug.<extension> Example: 20240811_143052_123_github-com-smnandre.png
function generateFilename(string $url, string $directory, string $extension = 'png'): string
slugifyUrl()
stringSlugify a URL for use in filenames.
function slugifyUrl(string $url, int $maxLength = 40): string
ensureDirectoryExists()
voidEnsure a directory exists, creating it if necessary.
function ensureDirectoryExists(string $directory): void
cleanupOldScreenshots()
intClean up old screenshots in a directory.
function cleanupOldScreenshots(string $directory, int $maxAge = 604800, int $maxFiles = 100): int
getDirectoryInfo()
arrayGet information about screenshots in a directory.
function getDirectoryInfo(string $directory): array