Skip to content

Commit 9142d65

Browse files
committed
Add screenshots after each test in the Allure reports
1 parent 806e79f commit 9142d65

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/test/java/com/serenitydojo/playwright/toolshop/contact/ContactFormTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,16 @@ void completeForm(Page page) throws URISyntaxException {
7171
Path fileToUpload = Paths.get(ClassLoader.getSystemResource("data/sample-data.txt").toURI());
7272
contactForm.setAttachment(fileToUpload);
7373

74+
recordScreenshot(page, "Submit form");
75+
contactForm.submitForm();
76+
7477
Assertions.assertThat(contactForm.getAlertMessage())
7578
.contains("Thanks for your message! We will contact you shortly.");
7679
}
7780

7881
@Step
7982
void submitTheForm(Page page) {
80-
recordScreenshot(page, "Submit form");
81-
contactForm.submitForm();
83+
8284
}
8385

8486
@Story("Submitting a request")
@@ -96,7 +98,8 @@ void mandatoryFields(String fieldName, Page page) {
9698
// Clear one of the fields
9799
contactForm.clearField(fieldName);
98100

99-
submitTheForm(page);
101+
recordScreenshot(page, "Submit form");
102+
contactForm.submitForm();
100103

101104
// Check the error message for that field
102105
var errorMessage = page.getByRole(AriaRole.ALERT).getByText(fieldName + " is required");
@@ -115,7 +118,8 @@ void messageTooShort(Page page) {
115118
contactForm.setMessage("A short long message.");
116119
contactForm.selectSubject("Warranty");
117120

118-
submitTheForm(page);
121+
recordScreenshot(page, "Submit form");
122+
contactForm.submitForm();
119123

120124
assertThat(page.getByRole(AriaRole.ALERT)).hasText("Message must be minimal 50 characters");
121125
}
@@ -131,7 +135,8 @@ void invalidEmailField(String invalidEmail, Page page) {
131135
contactForm.setMessage("A very long message to the warranty service about a warranty on a product!");
132136
contactForm.selectSubject("Warranty");
133137

134-
submitTheForm(page);
138+
recordScreenshot(page, "Submit form");
139+
contactForm.submitForm();
135140

136141
assertThat(page.getByRole(AriaRole.ALERT)).hasText("Email format is invalid");
137142
}

0 commit comments

Comments
 (0)