I'm trying to learn Java and using Selenium for my AQA tests.
Here's a dummy website that offers different kind of forms / pages / buttons to train: https://play1.automationcamp.ir/forms.html?
I'm working with "Form with Validations" section.
The test that I'm trying to create should check that the field / Terms and conditions label styles are changed accordingly after performing these actions:
- All fields are filled with valid data
- Terms and Conditions checkbox is clicked
- Submit button is pressed
The issue arises when Im trying to submit the form. The styles are changed accordingly. BUT - after a split second they are changed back to their default state. This prevents me from checking the state of the fields styles right after clicking on the the "Submit" button.
I've tried to create a custom method that will wait exactly for the moment when the styles are changed and THEN - stop any DOM updates. But of course, I was unsuccessful in it.
Heres the Test:
@Test
public void checkSuccessfulFormSubmission() throws InterruptedException {
SoftAssertions soft = new SoftAssertions();
BaseOperations.navigateTo(URLs.FORMS_PAGE);
ValidationForm page = new ValidationForm(getDriver());
page.setDataForAllFields(getDriver());
page.getTermsCheckbox().click();
page.getSubmitButton().click();
page.waitForValidatedForm();
soft.assertThat(page.isAllFieldsSuccess()).isTrue();
soft.assertAll();
}
And here's the waiting method that I'm trying to work on:
public void waitForValidatedForm() throws InterruptedException {
List<WebElement> elements = getAllInputs();
BaseOperations.getWait().until(driver1 -> {
Boolean isAllInputSuccess = elements.stream()
.allMatch(element -> getBorderColorCssPropertyValue(element).equalsIgnoreCase(getExpectedSuccessBorderValidateColor()));
for (WebElement element : elements) {
getBorderColorCssPropertyValue(element);
}
Boolean isLabelSuccess = getTermsLabel().getCssValue("color").equalsIgnoreCase(getExpectedTextSuccessColor());
log.info(getTermsLabel().getCssValue("color"));
return isAllInputSuccess && isLabelSuccess;
});
Thread.sleep(1000);
}
I'm welcoming any suggestions / approaches that will help me to complete this check.
Thanks!
========
I know its hard to understand fully what's going on in the test that I have written so far, so for a reference - here's a link to my GitHub repository that contains all helper methods for this particular Form: GitHub Link