Design Patterns in Test Automation Uh Hih
Design Patterns in Test Automation Uh Hih
8
7
This article highlights the design patterns & architectural considerations to take
6
into account when building a Selenium-based / Appium-based Test Automation
5
Framework. The examples are purposely shown in various programming
4
languages to highlight that this thought process is applicable for any
3
programming language you use for building an Automation Framework.
2
Table of Contents – Design Patterns in Test Automation
1
. Selenium WebDriver 101
. Why do we need a Test Automation Framework?
. Criteria for building a Test Automation Framework
. Design Patterns in Test Automation Framework
. Characteristics of a good Page-Object Pattern implementation
. Challenges of using Page-Object Pattern
. Solution: Business-Layer Page-Object Pattern
. Test Automation Framework Architecture
driver.get("http://localhost:8082/community-app");
var element = driver.findElement(webdriver.By.id("uid"));
element.sendKeys("mifos");
var value = element.getAttribute("value");
value.then(function(value) {
assert.equal(value, "mifos");
});
});
});
object.
○ On unsuccessful login, the method should return the same
LoginPage object.
○ There would be cases when you are getting information from the
@Test
public void shouldRevertToOriginalContentAfterClickingCancel() {
patientChartPage.updateName(newFirstName, newLastName);
patientChartPage.updateAddressLine(newLine1, newLine2);
patientChartPage.updateCity(newCity);
patientChartPage.updateState(newState);
patientChartPage.updateZip(newZip);
patientChartPage.cancelUpdate();
@Test
public void
shouldUpdateExistingPatientWithNewInformationAfterClickingSave() throws
InterruptedException {
registrationPage.registerPatientWithBasicInformation(expectedPatientInformati
on);
patientChartPage.updateName(newFirstName, newLastName);
patientChartPage.updateAddressLine(newLine1, newLine2);
patientChartPage.updateCity(newCity);
patientChartPage.updateState(newState);
patientChartPage.updateZip(newZip);
patientChartPage.saveUpdate();
Driver.get().navigate().refresh();
assertThat(patientChartPage.getFirstName(), is(newFirstName));
assertThat(patientChartPage.getLastName()), is(newLastName));
assertThat(patientChartPage.getCity(), is(newCity));
assertThat(patientChartPage.getState(), is(newState));
assertThat(patientChartPage.getAddressLine1()), is(newLine1));
assertThat(patientChartPage.getAddressLine2()), is(newLine2));
assertThat(patientChartPage.getZip()), is(newZip));
}
waitForElementToBePresent(driver.findElementByAccessibilityId(appliedPromoc
odeNameId));
eyes.checkWindow("isPromoCodeApplySuccessful");
return
driver.findElementByAccessibilityId(appliedPromocodeNameId).getText().equals
IgnoreCase(promoCode);
}
References:
● Sample github repository: https://github.com/anandbagmar/cuke-jvm-
sample
● Perils of Page-Object Pattern: https://www.slideshare.net/abagmar/
perils-of-pageobject-pattern
● Criteria for building a good Test Automation Framework: Test
Automation in the World of AI & ML (https://www.infoq.com/articles/
test-automation-ai-ml/)