TABLE OF CONTENTS
3.1 How to Enable a Soft Assertion for a web
1. Assertions Overview
Assertions serve as validations or checkpoints within an application, confirming whether the expected behavior is met. They act as statements of confidence regarding the application's functionality. For example, in a web automation, assertions validate automated test cases, assisting testers in determining whether tests have passed or failed.
Following are the two types of assertions:
2. Hard Assertions
Hard assertions, also known as regular assertions in a test automation that validate a condition and immediately stops the test execution if the condition is not met. When a hard assertion fails, it shows an 'AssertionError, ' which halts the test execution and marks the test as failed.
3. Soft Assertions
When the assertion fails, it terminates or aborts the test. If the tester does not want to terminate the script, they can use soft assertions. Soft assertions allow you to collect multiple assertion failures during a test case execution, instead of failing the test immediately after the first assertion failure. This allows you to continue executing the test case and gather information about all the failures before marking the test as failed. Soft assertions are useful when you want to verify multiple conditions in a single test case without stopping at the first failure.
The following screenshot displays a sample report with soft assertion enabled for a web automation using Java Selenium framework. In the scenario when the user clicks the is verified in a scenario, an error message is shown when the verification step fails. However, the test case execution continues using a soft assertion.
In the preceding example, the last step displays all the assertions.
Alternatively, if you wish to skip the default last step, then you can use the 'verify assert all' default action.
3.1 How to Enable a Soft Assertion for a web
Perform the following:
After generating the script, download it to your local folder. This folder must contain the script file that you have generated.
- Open the folder where you downloaded the script. For example, if your script is located at AlgoAFScript_202402121131\src\test\java, navigate to this folderApplications.xml file will be available in the Java folder as shown:
- In the ApplicationSettings.xml file, set the EnableSoftAssertion to True, save the changes you have made to the application settings file as shown in the example screenshot:
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article