99import com .serenitydojo .playwright .toolshop .fixtures .RecordsAllureScreenshots ;
1010import com .serenitydojo .playwright .toolshop .catalog .pageobjects .NavBar ;
1111import io .qameta .allure .Feature ;
12+ import io .qameta .allure .Step ;
1213import io .qameta .allure .Story ;
1314import org .assertj .core .api .Assertions ;
1415import 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