What does hybrid approach to test automation mean?
It's a strategic approach that aims to support better maintainability and reduce flakiness in end-to-end (E2E) test automation. This approach involves using a combination of API tests and UI tests.
In scenarios where certain prerequisites must be met before attempting the actual test, we can use endpoint calls/API tests to achieve these prerequisites. Then, we can use webdriver tests for UI-level functional validations/assertions.
By using this approach, we can redice the flakiness that may come from webdriver tests due to delays, object changes, and other issues. This approach is particularly useful for sections of the test case that are outside the main test case.
Let me explain with an example:
In here we are doing a mandatry field validation check; Our featue file is as below;
Scenario: Mandatory fields validation Given I am a registered user And I go to the accounts page And I leave the basic salary field blank When I try to move to the next page Then a validation error message is displayed for the basic salary field
My step definition will be like this;
public class MandatoryFieldsValidationStepDefinitions { @Given("I am a registered user") public void iAmARegisteredUser() { // Code to implement the Creat user step using RestAssured API } @And("I go to the accounts page") public void iGoToTheAccountsPage() { // Code to implement the "And" step using Appium // Navigate to the accounts page using Appium } @And("I leave the basic salary field blank") public void iLeaveTheBasicSalaryFieldBlank() { // Code to implement the "And" step using Appium // Find the basic salary field element and clear its value } @When("I try to move to the next page") public void iTryToMoveToTheNextPage() { // Code to implement the "When" step using Appium // Find the "Next" button element and click it } @Then("a validation error message is displayed for the basic salary field") public void aValidationErrorMessageIsDisplayedForTheBasicSalaryField() { // Code to implement the "Then" step using Appium // Find the error message element for the basic salary field and verify it is displayed } }
So how do we support this in our test framework? Since the CucumberRunner takes care of executing the features by mapping them with the correct step definition, all we have to do is ensure that our design is correct and that relevant API testing and webdriver libraries are included in the project.
A sample automation framework structure for a Maven project is shown below;
No comments:
Post a Comment