Simple touch on test automation frameworks
Most of the automation tests engineers do use one set of frameworks to maintain their code for reusability and for easy maintenance. These automation scripts are mainly used for Regression testing, Smoke testing and end-to-end testing. Also used when a repeatable task needs to be achieved for a number of times. One of the well known frameworks is Page Object Model also known as POM framework. POM in addition with Behaviour Driven Development model, also known as BDD is a perfect combination for UI automation.
To keep a clean separation between test and page specific methods. Each page will be having web elements and their access methods. When web element locators are changing then it is easy to locate and change accordingly in the specific page as it uses object repository.
Complete flow of POM with BDD
POM with BDD framework can be implemented with different tools like Selenium WebDriver or Playwright, Junit, TestNG, Maven, Cucumber etc.
Directory structure in POM framework
src/main/pages - contains all the methods for the web pages.
src/main/utils - contains all the reusable methods.
src/tests - contains Test code.
target - contains Output generated.
Pom.xml – contains all the Maven dependencies for the project.
POM with BDD
Page Object Model with BDD design pattern helps to bring both technical and business/ non-technical users together. Cucumber supports BDD design pattern for automation testing. POM with BDD solution offers to write the acceptance criteria in Gherkin language, which is a simple Given, When & Then format; helps to meet the acceptance criteria.
Cucumber Runner Class
The Runner class gives an option to execute scenarios according the tags provided in scenario and feature level. Cucumber hooks and tags will greatly help in selecting the required group of tests. Without touching the automation code can be executed for the required set of tests.
Example: @smoke, @Regression,@EndToEnd, @All-tests etc.
At the end we can generate beautiful graphical Cucumber reports.
Advantages of POM with BDD
- Easy to understand the flow of code and easy to maintain
- Easy to get the test coverage
- Easy to work in collaboration
- It brings technical and business users together
- It can be used for Selenium or Playwright etc
- Tests can be logically grouped and executed
- Cucumber Reports can be automatically generated
- It can be integrated with CI/CD pipeline.