Skip to content

Commit 806e79f

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

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.serenitydojo.playwright.toolshop.fixtures.RecordsAllureScreenshots;
1010
import com.serenitydojo.playwright.toolshop.catalog.pageobjects.NavBar;
1111
import io.qameta.allure.Feature;
12+
import io.qameta.allure.Step;
1213
import io.qameta.allure.Story;
1314
import org.assertj.core.api.Assertions;
1415
import org.junit.jupiter.api.*;
@@ -70,13 +71,16 @@ void completeForm(Page page) throws URISyntaxException {
7071
Path fileToUpload = Paths.get(ClassLoader.getSystemResource("data/sample-data.txt").toURI());
7172
contactForm.setAttachment(fileToUpload);
7273

73-
recordScreenshot(page, "Submit form");
74-
contactForm.submitForm();
75-
7674
Assertions.assertThat(contactForm.getAlertMessage())
7775
.contains("Thanks for your message! We will contact you shortly.");
7876
}
7977

78+
@Step
79+
void submitTheForm(Page page) {
80+
recordScreenshot(page, "Submit form");
81+
contactForm.submitForm();
82+
}
83+
8084
@Story("Submitting a request")
8185
@DisplayName("First name, last name, email and message are mandatory")
8286
@ParameterizedTest(name = "{arguments} is a mandatory field")
@@ -92,7 +96,7 @@ void mandatoryFields(String fieldName, Page page) {
9296
// Clear one of the fields
9397
contactForm.clearField(fieldName);
9498

95-
contactForm.submitForm();
99+
submitTheForm(page);
96100

97101
// Check the error message for that field
98102
var errorMessage = page.getByRole(AriaRole.ALERT).getByText(fieldName + " is required");
@@ -111,7 +115,7 @@ void messageTooShort(Page page) {
111115
contactForm.setMessage("A short long message.");
112116
contactForm.selectSubject("Warranty");
113117

114-
contactForm.submitForm();
118+
submitTheForm(page);
115119

116120
assertThat(page.getByRole(AriaRole.ALERT)).hasText("Message must be minimal 50 characters");
117121
}
@@ -127,7 +131,7 @@ void invalidEmailField(String invalidEmail, Page page) {
127131
contactForm.setMessage("A very long message to the warranty service about a warranty on a product!");
128132
contactForm.selectSubject("Warranty");
129133

130-
contactForm.submitForm();
134+
submitTheForm(page);
131135

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

0 commit comments

Comments
 (0)