Page Object Model - Implementation

In the previous post, we discussed Page Object Model concepts. In this post, discussing its implementation with Python and Java

Python Implementation

Let's look into the implementation with Python. The framework has developed with PyTest. The folder structure of the test suite is given below

The base class file name is UIBase.py and it contains the commonly used UI methods such as click, enter_text, assert_text, etc

Let's have a look at page object class files. we've two class files, are Login and Registration. As mentioned in the previous post, The page object class file should contain the UI elements and methods associated with the Login page

Now we're looking at how the test class files are created. Class files are created in the AAA pattern like Arrange, Act and Assert. All tests are independent, Have a look at the below code snippet

The complete framework is available in the git repository 

Java Implementation 

Technically, there is no difference with the above implementation. There are page object class files and test class files. Please have a look at its Github repository. 

Page Object Model Automation framework - Explaining with a scenario

As mentioned in the starting post. This section explaining Page object model with a scenario. Let's say you've got a Login and Registration page to automate. I've created an application with the help of the Python Flask framework and we can use it for explaining the scenario. The application has two pages, Login and Registration as shown below

Login page

Registration page


In the Page Object Model (POM), we need to create a class file for each page such as Login and Registration. The class file should contain all the UI elements and methods of the corresponding page. It is a page object and using this page object the test can communicate to the Application to be tested (AUT).  Please have a look at the below diagram 

Base class - The base class contains common test methods like Wait_for_Element, Click_Element and Common methods, etc 

Login and Registration class - Login and Registration classes are inherited from the Base class. It should contain the UI elements and methods required. Each class file should be independent and should not share any common code. Let's have an example with the Login class, it should contain the UI properties of the Username, Password, and Submit button and its methods are login()invalid_username()invalid_password() etc.

Test class files - Login and Registration test class files need to access their corresponding page object class and prepare the test. The tests are should be independent and it enhances moduluariazation 



Page object model Automation framework

Page Object Model (POM) is one of the widely used automation frameworks. The main advantages of this framework are less test maintenance and reducing code duplication. This topic has divided into two sections, The first section talks about Whats Page Object Model and the next section about its Implementation

Post 1: What is Page Object Model - Explaining with a scenario

Post 2: Implementation - Example with Python and Java


Configuring REST Assured with Gradle

Gradle is one of the widely used build automation tool nowadays. In this tutorial, we're talking about configuring the REST Assured libraries with the Gradle tool. This build tool would definitely save the time for configuring the selenium libraries manually 


As a first step, you need to create a blank Gradle project and this can be done via your IDE for eg: Eclipse. Once you created, you need to find the build file build.gradle under the Gradle project. In this file, we need to mention the required REST Assured libraries. Please look into the a sample build.gradle file, here you can see the required depedencies added under the section dependencies. When you build the project after this, you can see that all configured librareis got downloaded under the project and it saves the time for configuring the libraries manually !!

Integrating automation suite with Azure pipeline

 Azure DevOps provides features like version control, requirement management, testing, automated builds, etc. The entire product life cycle can be covered using its DevOps services. In this tutorial, we're talking about the integration of an automation suite with Azure Pipeline.

Azure Pipelines allow you to automatically run builds, perform tests, and release the artifacts to the required environments. Azure Pipelines is created in the form of YAML files and it has stages of every action like download the code, build it, deploy it, run automation suites and publish the results 

We've created an automation suite for this post and which is available in GitHub. The automation suite which is written in Python. In this repository, you can find the YAML file which is named as smoketest-pipeline.yml. Let's have a look into each stage

The first stage is used for declaring the variables, in which root directory and url are supplied

The second stage is talking about pulling the code from repositories 

The next stage is about machine details in which the pipeline should run. Users can specify the operating system type and other configurations. Since it is a Python project, Python version has specified

The fourth stage, installing the required packages for the automation suite

The last stage, running the automation suite

This is about the structure of YAML file and let's look into its execution part. Navigate to Azure Devops and select the Pipeline from your repository then Run it. You can see its status of each stage 


This is a simple YAML file and there are different stages available that should definitely meet your needs.