The Soft Assertion with Screenshots enhances the basic Soft Assertion feature by allowing you to capture screenshots for every failure that occurs during the test. Instead of stopping the test execution upon the first failure, this assertion continues running all tests and captures a screenshot for each failure. This provides a comprehensive view of test results with visual documentation for each issue encountered.
You can see the screenshots in the target/screenshots folder and in the reports.
Here is an example of using soft assertions with screenshots:
import co.verisoft.fw.asserts.SoftAssertsScreenShot;
@Test
public void AssertWithScreenshot(VerisoftDriver driver){
SoftAssertsScreenShot softAssertsScreenShot = new SoftAssertsScreenShot(driver);
boolean condition1 = false;
boolean condition2 = false;
driver.get("https://google.com/");
softAssertsScreenShot.assertTrue(condition1 ,"fail");
driver.get("https://translate.google.com/");
softAssertsScreenShot.assertTrue(condition2 ,"fail");
softAssertsScreenShot.assertAll();
}
In the example shown here, where both options are set to false, it captures a screenshot for each failure. At the end, it presents all the failures in sequence, providing a visual display for each failure.