Book Excerpt - Science of Selenium - Ch-8 Building a Test Automation Framework with Selenium
Kalilur Rahman
Director @ Novartis | Technology Transformation Leader| Author | Ex-Accenture/Cognizant/TCS | Life Long Learner | Quizzer | Mentor | Speaker | Influencer | Operations | Consulting | Quality Engineering
Dear All
Using this forum to share some excerpts to raise the interest levels of the book I wrote and published through BPB Publications. I will share some excerpts every week to get your inputs and suggestions for future work.
This week, I am focusing on the Chapter - 8 Building a Test Automation Framework with Selenium. This covers the following aspects
Table of Contents
Chapter 8 explores the strategy, which one needs to keep in mind at the time of deciding a test automation framework. This chapter explores various aspects of test automation approaches. This chapter focuses more on the theoretical and concept-based understanding of test automation.
Chapter 8 Building a Test Automation Framework with Selenium
“Why did the Roman Empire collapse? What is Latin for office Automation?”
– Alan J Perlis
One of the most important aspects of any test automation project is the requirement to build a test automation framework. This includes multiple tasks in addition to coding in selenium. Building a good test automation framework requires a meticulous planning mind with the end state and long-term vision of the organization in mind. In this chapter, we will take a look at one type of approach we could follow for establishing a test automation framework with Selenium. This chapter will be a conceptual one in nature and we will have a technical implementation discussion in the next chapter.
Structure
We will look at the following concepts to test the automation knowledge. We shall also look at some reference and tips to the following points.
Test Automation Strategy/Approach:
- Building an Automation Strategy
- Choosing a Programming Language
- Defining the Automation Framework Architecture
- Choosing a Unit Test Framework
- Designing Core Components of a Framework – Modularization
- Designing Test Components of a Framework
- Designing Reporting Mechanism
- How to perform Source Code Control, Build, and Continuous integration if used in DevOps
- How to integrate with Other Tools
Building a Test Automation Strategy
We have tremendous growth in computerization and business processes are automated as a result. The expansion of Industry 3.0 led innovation (i.e. computerized automation), the amount of codegenerated, and the business logic and functionality getting added is increasing phenomenally as well.
With the approaches taken by businesses and a move towards continuous testing, concepts such as DevOps and Continuous integration will cause a major dent in the manual testing of end-to-end processes, applications, etc. Test automation is a key to deliver value the organizations will be looking forward.
However, an extensive dependency on the UI/front-end based automation may not work in the current age and context. Continuous automation need not happen only at the UI level but it can be done much earlier by inverting the testing Pyramid. What it means is that we can automate testing of APIs, microservices, and interfaces at an earlier phase of SDLC.
It is also important for the organization to decide what can be automated, why it should be automated, and how it can be automated before embarking on a journey in test automation. To achieve this, building a test automation strategy is the first step of a test automation project.
One of the sample approaches for building a Test Automation Strategy may look like the figure 8.1 below There could be more than one way to decide on a test automation approach and a one-size-fits-all approach may not apply to different organizations and units.
Key actions for building a test automation strategy
For building a good automation strategy, the test automation architect needs to ask some important questions before finalizing the strategy. Some of the questions are as follows:
Determine the need for automation:
To determine the need for automation, it is important to analyze and understand if there should be any automation. Automation is not a silver bullet to all the problems unless it is done in a very thorough and well- thought manner. Hence, the first important question is to determinewhen it would be the right time to automate. Is it early in the development in the lifecycle Vs. just before-go-live and in-cycle automation vs. stable phase automation are some of the questions the project team needs to address.
Which test automation tool to choose?
Some questions to look for while deciding the test automation tool to use would be what are the features you should be looking at for your test automation framework? Is it functionality or affordability of the tool that you are looking for? Is it the ease of use or the features? Is it the extensibility or compatibility that you are looking for?
Automation test script selection:
As mentioned earlier, 100% test automation is a myth and purposeful and meaningful automation is key to the success of a test automation program. Some of the questions to be asked are as follows:
- Does the test case get executed multiple times repeatedly?
- Doesthe test case require manual intervention and verification checks? Are there any pre and postcondition checks to be done?
- Are the steps to be followed unambiguous? What are the test data needs for the test case?
- Are test conditions and expected results very clear? Can the script be modularized?
- Is the script straightforward or complex?
- Is there a long term need and goal to use test automation? Is it strategic or use and throw approach?
- Is the automation required for regression testing or a new functionality? Is there a need for test script and test data reusability via automation? Is there a progressive growth of features in the application/product under test? (i.e) Is there an increasing need for regression testing?
- Are the requirements clear and not volatile?
All these questions and the steps outlined in Figure 8.1 give a method to build a solid test automation strategy.
Choosing a programming language
There are a lot of options available to do test automation using a myriad of programming languages and tools. Some of the tools do not mandate extensive programming knowledge. However, some of the tools/frameworks require a very good programming language in various languages to build a solid test automation framework.
Selenium is such a framework built on a brilliant programming approach followed by a genius tester. As the requirements for test automation vary across applications and products, it is important to choose a programming language that can deliver the requirements for building a solid test automation strategy.
One challenge to remember is that once you decide to go ahead with a programming language for test automation; for example, VB Script for MicroFocus UFT or JavaScript for Protractor, your investment gets locked in a way. However, with a flexible framework such as Selenium, one has an opportunity to automate in multiple languages such as Java, JavaScript, Ruby, C#, Python, PHP, etc. This allows users to use common libraries available in multiple languages.
However, it may take away the efficiency a framework gives in terms of common functions and libraries written in one language to be compatible in another. The key to success is to choose a language that makes your application in a decent state to be migrated to any new automation tool or framework your project/application team decides to use.
Defining the automation framework architecture
One of the most important aspects to choose a test automation strategy is the decision on the automation tool and the type of automation; Be it scripted or script- less automation. If one needs to script in a tool using a programming language, availability of skills, ease of programming, ability to generate modularized scripts and libraries, and ease of maintenance aspects need to be clearly understood and a decision needs to be made accordingly.
Test automation typically starts when the application is in the ‘golden window’ or when it is stable. However, a good practice will be to start focusing on features and functionalities that are not likely to change and progress with the modular model of testing even before the application is ready. This will be achieved via the use of good library/utility-based test automation by building objects and library functions for use in test automation. This could be at an object or a user action element level.
For the Page Object Model, test automation engineers can use the abstraction-based approach. It is also important to start automaton in earlier phases by inverting the test pyramid as it useful for the application developers to build high-quality build before it is made available for testing.
Once the framework is finalized, the implementation team needs to ensure that the core principles are maintained with a future centric vision in mind. Things such as the ability to port into a new tool, ease of maintenance, and the ability to minimize the maintenance of test automation script are some of these essentials.
......
......
......
INTENTIONALLY LEFT BLANK
.....
......
.....
How to perform Source Code Control, Build, and Continuous Integration in DevOps
One of the greatest benefits of the DevOps model is to leverage the automation tools available to build a release pipeline. Automated code built using Selenium can be integrated with other tools to make this happen seamlessly.
One of the biggest challenges faced by developers and automation scriptwriting testers is the ability to version control and manage the code. It becomes critical for the team to ensure the right versioning is done and an automated build is done as soon as the code is committed. To do automated build and for source control, the team can leverage tools such as GitHub, Subversion, Gitlab, Artifactory, and Bitbucket to name a few. Traditional source code control by legacy firms can also be used but the level of integration could be tricky.
When used with Continuous integration tools such as Jenkins, Bamboo, Travis, Circle, Teamcity,+ AWS Code build, Microsoft VSTS, Codeship, etc., we can achieve the objective of doing an end-to-end build of automated test scripts.
For Continuous Build, one can pick from Ant, Maven, JAM, Gulp, and other tools. This purely depends on how you have built the Continuous Integration pipeline for your project and environment.
How to integrate with other tools
One of the key aspects of the end-to-end continuous integration is to build your release pipeline. This could be a unique pipeline with different sets of tools and technologies followed based on the need. Every pipeline is unique by nature and there is no one-size-fits-all template of a build pipeline applicable to all types of enterprises and customers. As a part of the strategy, it is important to decide the need first and understand the capabilities of the tools involved and the amount of programming/coding/ integration needed before deciding on the tools, infrastructure and methods to implement.
Conclusion
In this chapter, we covered the key essentials for building a test automation framework. In the next chapter, we willsee some of the advanced features of selenium test automation such as the Page Object Model and how we can bring the entire test automation framework components into the picture. Having a strong grasp of the basics of test automation components, how to interweave them together to build a solid framework having a strong approach for test automation and being flexible to accommodate the futuristic changes will be a key to successful implementation. In the next chapter, we willcover some of the most important topics in Selenium such as creating a Page Object Model, how to do file and database interactions, how to setup reporting in Selenium, how to integrate with the CI/CD pipeline, and other topics that are crucial for implementation of a good test automation framework.
Questions
- Why building a test automation framework is important?
- What are some of the core components to be considered while building a framework?
- Why is source control management important in a test automation project?
- What are some of the continuous integration tools that we can use for building a test automation framework?
- What is meant by a test automation controller? How can you implement a test automation controller using Selenium?
- What is the benefit of modularization in test automation framework? How will you implement Modularization?
- What are the benefits of using libraries in a test automation framework?
- How will you go about implementing one? What are some of the good build tools available?
- What will be your approach to test automation framework for a product getting built in an agile fashion? When and what will you automate?
- What are some of the challenges faced while doing test automation maintenance? What would be your ideas to overcome them?
END
Hope you enjoyed the excerpts from Chapter-8. What are your comments?
Book Availability
The book is available at the following sites
- Australia ==> Amazon ==> https://www.amazon.com.au/dp/B082KFY17B
- Austria ==> Amazon ==> https://www.amazon.de/dp/B082KFY17B
- Brasil ==> Amazon ==> https://www.amazon.com.br/dp/B082KFY17B
- Canada ==> Amazon ==> https://www.amazon.ca/dp/B082KFY17B
- Czech Republic ==> Amazon ==> https://www.amazon.de/dp/B082KFY17B
- France ==> Amazon ==> https://www.amazon.fr/dp/B082KFY17B
- Germany ==> Amazon ==> https://www.amazon.de/dp/B082KFY17B
- India ==> Amazon ==> https://www.amazon.in/dp/B082KFY17B
- India ==> Amazon ==> https://www.amazon.in/dp/B082KFY17B/ref=dp-kindle-redirect?_encoding=UTF8&btkr=1
- India ==> Amazon ==> https://www.amazon.in/Science-Selenium-Automation-Framework-English-ebook/dp/B082KFY17B
- Italy ==> Amazon ==> https://www.amazon.fr/dp/B082KFY17B
- Japan ==> Amazon ==> https://www.amazon.co.jp/dp/B082KFY17B
- Japan ==> Amazon ==> https://www.amazon.co.jp/Science-Selenium-Automation-Framework-English-ebook/dp/B082KFY17B
- Mexico ==> Amazon ==> https://www.amazon.com.mx/dp/B082KFY17B
- Spain ==> Amazon ==> https://www.amazon.es/dp/B082KFY17B
- Switzerland ==> Amazon ==> https://www.amazon.de/dp/B082KFY17B
- UK ==> Amazon ==> https://www.amazon.co.uk/dp/B082KFY17B
- USA ==> Amazon ==> https://www.amazon.com/dp/B082KFY17B
- USA ==> Amazon ==> https://www.amazon.com/Science-Selenium-Automation-Framework-English-ebook/dp/B082KFY17B
- USA ==> Barnes & Noble ==> https://www.barnesandnoble.com/w/science-of-selenium-kalilur-rahman/1135502525?ean=2940163963881
- Brasil ==> Livrariacultura ==> https://www3.livrariacultura.com.br/science-of-selenium-2012821784/p
- Canada ==> Indigo ==> https://www.chapters.indigo.ca/en-ca/books/science-of-selenium/9789389423242-item.html
- Canada ==> Indigo ==> https://www.chapters.indigo.ca/fr-ca/livres/science-of-selenium/9789389423242-article.html
- Germany ==> WetBild ==> https://www.weltbild.de/artikel/ebook/science-of-selenium_26964037-1
- Germany ==> WetBild ==> https://www.weltbild.de/artikel/ebook/science-of-selenium_26964037-1
- Global ==> Google Play ==> https://play.google.com/store/books/details/Kalilur_Rahman_Science_of_Selenium?id=-ofCDwAAQBAJ
- Global ==> Review Site ==> https://www.goodreads.com/book/show/49289577-science-of-selenium
- Global ==> Scribd ==> https://www.scribd.com/book/439434766/Science-of-Selenium
- Global ==> Textbookx ==> https://www.textbookx.com/book/Science-of-Selenium-Master-Skills-Needed-to-Become-a-Top-Test-Automation-Guru-with-Easytofollow-Selenium-Examples/9789389423242/
- Holland ==> Bol ==> https://www.bol.com/nl/p/science-of-selenium/9200000126647725/
- India ==> BPB Publications ==> https://bpbonline.com/products/science-of-selenium-master-web-ui-automation-and-create-your-own-test-automation-framework
- India ==> PayTM Mall ==> https://paytmmall.com/science-of-selenium-RKC0003512361_882733-pdp
- India ==> SapnaOnline ==> https://www.sapnaonline.com/books/science-selenium-master-web-ui-kalilur-rahman-9389423244-9789389423242?position=2&searchString=science%20of%20selenium
- India ==> Snapdeal ==> https://www.snapdeal.com/product/science-of-selenium/626675025728
- Japan ==> Rakuten ==> https://books.rakuten.co.jp/rk/7a977206400b37fb90e0057fc90225a7/
- Portugal ==> FNAC ==> https://www.fnac.pt/livre-numerique/a7376163/Science-of-Selenium
- Saudi Arabia ==> Google Play ==> https://play.google.com/store/books/details/Science_of_Selenium_Master_Web_UI_Automation_and_C?id=-ofCDwAAQBAJ&hl=ar
- Saudi Arabia ==> VitalSource ==> https://www.vitalsource.com/sa/en-us/products/science-of-selenium-master-skills-needed-to-kalilur-rahman-v9789389423242
- Serbia ==> Kombib ==> https://knjige.kombib.rs/science-of-selenium-master-web-ui-automation-and-create-your-own-test-automation-framework
- Spain ==> FNAC ==> https://www.fnac.es/livre-numerique/a7147532/Science-of-Selenium
- Sweden ==> BOKUS ==> https://www.bokus.com/bok/9789389423242/science-of-selenium/
- USA ==> Tattered Cover ==> https://www.tatteredcover.com/book/9789389423242
- USA ==> Walmart ==> https://www.walmart.com/ip/Science-of-Selenium-eBook/466432367
Note:- Title Images are created using CANVA tools. Authors of the quote referred where known. Most of the information shared is generic and available in various forms in the Internet. Respective trademarks are owned by corresponding firms. Opinions about tools highlighted are from a personal experience standpoint and in no way reflect the views of my current or past employers or clients.
#WhatInspiresMe #Automation #Selenium #KRPoints #TestAutomation #DevOps #AITesting #NewAgeTesting #MobileTestAutomation
??
Very beneficial write up Kalilur Rahman
TEDx Speaker ?? Serial Entrepreneur ?? Startup Advisor ??Personal Branding ?? Storyteller ?? Strategic Innovation? Published Author ??
4 年Thank you Kalilur Rahman
???????? 8??9?? K+ COMMUNITY? STRATEGIC PRODUCT MANAGEMENT ?? MARKETING ENTHUSIAST ?? 2??5?? Million Yearly Content Views ?? FOLLOW AND CONNECT ?? Do or do not - there is no try ??SMT & SEMICONDUCTOR SOLUTIONS??
4 年Fantatsic reminder about quality and price Kalilur Rahman
?? Award-Winning Executive Branding Specialist | I Help Executives Build a C-Suite Personal Brand | Founder & CEO - The Executive Brand | Advisor To The Royal Office UAE | International Speaker
4 年No doubt this will benefit many Kalilur Rahman