To set up an HTML reporter for Playwright Test with Java, follow these steps:
Install the Playwright Test library.
Create a playwright.config.ts
file in your project's root directory.
Define a reporter
option in the configuration file:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [['html', { outputFolder: 'my-report' }]],
});
This sets up an HTML reporter that generates reports in the my-report
folder.
If you want to upload attachments from a data folder to another location, use the attachmentsBaseURL
option:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [['html', { attachmentsBaseURL: 'https://ray.run/' }]],
});
To open the last test run report quickly, use this command:
npx playwright show-report
If there is a custom folder name specified in your configuration file (e.g., my-report
), use this command instead:
npx playwright show-report my-report
Note that the HTML reporter does not support merging reports generated across multiple shards into a single report. However, third-party solutions can help with this issue.
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].