1. Building Hybrid Test Automation Framework — Python

Ali Pala
4 min readOct 26, 2019

--

Hello all, I would like to tell you about my building a framework journey. The goal of these series is to give an idea for QA professionals who new to automated testing, or those who need a quick refresher. I used lots of libraries, tools, designs, and add-ons while creating the framework. Some of them are Python, Pytest, Pandas, Selenium, Allure Reports, Jenkins, Slack, Chropath, etc. Don’t worry, I will mention all the details and do many examples from scratch to build the framework. You can also find WHY questions? Why I chose Python for developing tests or why preferred Allure Report rather than Extent Report to generate a user-friendly report as an HTML. There will be a series of useful resources to create your framework by yourself.

If you are ready let’s discuss why we need to create a test automation framework. Before diving into the details, let’s clarify what a test automation framework actually means.

What is the Test Automation Framework?

A Test Automation Framework consists of a set of guidelines and rules used for creating and designing test cases. It is a combination of practices, tools, and libraries that work together by creating reusable code modules to provide an initial step for automation. It has also conventions, directions, and methods to make the process more efficient and less difficult. The framework could include coding standards, test or data handling methods, object repositories, processes for storing test results. A good Test Automation Framework can reduce the maintenance costs and testing efforts in an Agile environment by optimizing the process. After some explanation about how should be a Test Automation Framework looks like, let me start with Python.

Why I chose Python over Others?

To be honest, the whole story was started with my desire to learn Python. Everyone has been talking about Python in my company. There has been a significant amount of news, jobs, and area related to Python. After doing some practices and challenges in learning, I aware of Python is really easy to learn and manage. It is designed in a user-friendly manner. The syntax is more clear than the other programming languages. You can start to write code very fast. If you hear some advantages for using Python, I could say;

  1. Python runs very fast,
  2. You should pay attention using braces to start and ends blocks in other programming languages while python needs the only indentation,
  3. Python is dynamic typing. It means you don’t have to worry about types of variables while you are writing codes. It is quicker because you do not have to specify types every time. See the link below: https://stackoverflow.com/questions/1517582/what-is-the-difference-between-statically-typed-and-dynamically-typed-languages

I’d like yo also say something about writing test automation codes in Python. Tests should be easy to read and detailed because they describe the features under test. They should be clear about coverage. It should not be complex and make us confused. So, since Python’s elegance, it is an incredible language for test automation. In addition to these, unit testing libraries like “pytest”, packages which can be installed easily withpip install <package_name>and popularity among the communities make Python more attractive than the others.

How to Install Python?

You need to go to python.org to download it. After downloading is finished, the go-ahead to run the installer. Please be careful to enable the “Add Python 3.6 to PATH” option on the first window in installation.

You should see the setup completed successfully message at the end of the installation.

After installing Python, you need to add Python into System Variables to work with Python on the command line. To enable this, hit start and type “system variables” in Windows start and see the “System Properties” window.

In the “System Properties” window that opens, on the “Advanced” tab, click the “Environment Variables” button.

Go to the directory where you installed the Python. Copy the link and put it into the Path variable in the “System variables”.

For the last step, open command prompt, and type %python --versioınand see the version of installed Python.

That’s it! You can now use the “python” command at the Command Prompt.

These are the initial steps of the building framework. We will discuss Pytest as a testing framework. See you in the next article.

--

--

Ali Pala

Entrepreneur, Quality Coach, AI Enthusiast, Public Speaker, Trainer, Dad