Automation Testing Tutorial: A Starter’s Guide With Example

Ria Dayal

Posted On: April 7, 2022

view count41261 Views

Read time25 Min Read

Software testing is an integral part of any IT project. Testing the software more and more will ensure a better quality of your software. Now, how do you achieve it? Either you go with Manual Testing or Automation Testing.

Now sticking to manual testing can land you in trouble sometimes, as achieving Continuous Testing through manual testers can be really exhaustive. Moreover, manual testing is prone to human errors, is time-consuming, expensive, and can hit customer experience greatly.

Businesses are constantly pressured to improve, adapt, and become competitive. Keeping up with all the changes in the technology industry is an enormous challenge, and organizations, therefore, need to automate repetitive testing processes to ensure that software performs according to expectations and provides value in no time. This can happen by adopting agile methodologies to achieve shorter development cycles and accelerated Time to Market (TTM).

Having said that, in my opinion, manual testing still plays an imperative and indispensable role in the software development life cycle, though it has to be coupled with a formidable automation testing strategy.

In this automation testing tutorial, we will cover all about automation testing, the need for automation testing, and its different approaches. If you are preparing for an interview you can learn more through Automation Testing Interview Questions.

Let’s get started!

What is Automation Testing?

Automation testing is the process of carrying out the test activities using the assistance of tools, scripts, and software by repeating pre-defined actions.

In simple terms, you can understand automation testing as a type of testing that focuses on replacing repetitive, error-prone, and time-consuming manual tasks or activities with automated scripts in order to enhance the performance of the software and efficiency.

Testing is a very crucial activity in any Software Development Lifecycle. In order to ensure a better quality of your software, you need to ensure better testing of it. Automation testing gives testers the time to focus on other quality activities like performing exploratory tests, analyzing test results, etc., by taking over the repetitive and mundane tasks like Regression tests. As a result, automation testing enables you to achieve better test coverage in a shorter period of time.

Also ReadGet True Cross Browser Test Coverage With TestCafe & LambdaTest

Starting your journey with TestCafe Testing? Check out how you can test your TestCafe test scripts on LambdaTest’s online cloud.

Difference between Manual and Automation Testing

In this automation testing tutorial, let’s see what are the major differences between Manual and Automation Testing:

Features Manual Testing Automation Testing
Test Execution Done manually by the team members Done using automation tools and scripts
Test Efficiency Time-consuming and less efficient Saves time and is more efficient
Test Accuracy & Reliability Low, as manual tests are prone to human errors High, as no scope of human errors
Infrastructure Cost Low, Return of Investment is low Low (for the cloud-based test), Return Of Investment is high
Usage Suitable for Exploratory, Ad Hoc, and Usability Testing Suitable for Regression, Load, and Performance Testing
Coverage Difficult to ensure greater test coverage Easier to achieve greater test coverage

The above differences clearly indicate the effectiveness of automation testing. However, with manual testing, you benefit from human expertise and knowledge, which an automation testing tool can never provide a match for.

Hence, an ideal approach would always be to keep a combination of Manual + Automation activities for your testing cycle.

Also readHow To Move From Manual Testing To Automation

Run Selenium, Cypress, and Appium tests on LambdaTest to scale with the demand of your website and web apps.

Why Automation Testing?

Now that you have seen some of the major benefits of automation testing, let’s understand the need for automation testing through a practical use case.

You get a new feature to test in your software. You started your test plan, and there are some 50 test cases that you identified.

You started the tests and reported some 10 bugs in the first sprint. Those bugs keep getting fixed over sprints, and you have to test the updated version of the software with each build. Now, how do you ensure that the fix for one bug doesn’t affect the older working areas?

To ensure that, you need to test the complete software or perform regression testing after each bug fix. When the number of bugs in software increases or the number of features to test increases, manual testing may turn cumbersome. This is where automation testing comes in.

In such cases, you can simply automate the areas you have already tested and covered. Now, every time a new build or bug fix comes in, you can run the entire suite and easily ensure the health of your software.

Hence, with lesser time, you can achieve better coverage and quality of your software. An effective test automation strategy plays an important role in ensuring a bug-free application.

Automation testing life cycle

Automation testing life cycle mentioned above is a group of well-defined phases that result in an efficiently working test automation framework used to develop and maintain the software.

Also ReadTop 9 Challenges In Automation Testing [2022]

Which Test Cases To Automate?

Automation Testing has a lot of benefits and is well suitable for areas that require testing over and over again, but can we achieve 100% test automation?

Well, it’s difficult to achieve 100% test automation, and hence, it’s very important to determine which test case can be automated.

Let’s look at the areas where you can apply Automation Testing

  • Repetitive (Regression) Tests
  • These are the prime candidates for automation tests, as their numbers keep on increasing with the addition of new functionalities. As a result, they become difficult to maintain, and running them manually over and over again becomes a mundane task.

  • Complex Tests
  • Complex tests are best to automate. For example, consider the areas which require large calculations; they are always prone to human errors. Hence, automating them would always ensure the correct result of your software.

  • Smoke Tests
  • The smoke testing which probably need to be carried out in different environments like Dev Env, QA Env, and Production Envs are also good candidates for automation testing. It would save a lot of time by running these tests through automation every time a new environment comes in. This way, you can also cover tests over different browsers or OS flavors in less time.

  • Data-Driven Tests
  • These are the tests that require repeated testing with different data sets, and hence, automation testing can prove to be a boon in such cases.

  • Performance Tests
  • Automation testing will help you test the software performance and load under different conditions easily and in much lesser time as compared to the manual approach.

Learn all about Github actions for test automation with Gandhali Samant and how it can help testers execute tests on LambdaTest platform.

How to do Automation Testing?

Automation Testing Process

By Louise J Gibbs

The automated QA testing procedure, which often occurs concurrently with the software development life cycle, involves a number of significant steps. The actions that need to be taken in order to execute automation testing are listed below:

  1. Define Scope Of Automation
  2. Selecting a tool for automation
  3. Develop a plan
  4. Set the environment
  5. Develop a script
  6. Test Execution
  7. Maintain, Analyze and report

1. Define Scope Of Automation

Now that you have selected the best-suited test tool, the next step is to define the scope of your test automation. Consider the below points while defining the scope of automation:

  • The complexity of test cases
  • Technical feasibility
  • Common functionalities across applications
  • Reusability and Scalability of test cases for cross-browser testing

2. Selecting a tool for automation.

Before starting with any test automation, you need to decide which kind of tests you need to automate. Once you have the test definition ready, you need to select the correct set of tools that can help you in performing those tests. There are several testing tools available. The industry-standard tools for automated testing are based on code and code-based test scripts.

The most popular code-based web automation framework for automation testing is Selenium WebDriver, which allows you to test web applications using different browsers (Chrome, Firefox, Internet Explorer, etc.). It also supports many languages such as Java, Python, C#, etc. However, choosing the correct one is a very crucial step in an automation process.

Consider the below pointers when selecting an automation tool:

  • How easy is it to develop and maintain scripts using the test tool?
  • How many different platforms does the tool support? For e.g., Web, Mobile, Desktops, etc.
  • How many different languages is the tool compatible with?
  • Does the tool support a reporting mechanism?

3. Develop a plan

The Planning, Design & Development phase includes the below points:

  • Framework design & its features
  • Test case development
  • Test suite preparation, For e.g., Smoke, Sanity, Regression
  • Plugging framework with some CI/CD pipeline to achieve continuous testing.

4. Selecting a tool for automation.

Set up the essential infrastructure, which should include the testing environment, test data, and any special configurations or dependencies needed to perform the automated tests. This guarantees a constant and reliable testing environment.

5. Develop a script

Create test scripts utilizing the programming language and automation tool of your choice. These scripts ought to represent user interactions, check for anticipated results, and handle any assertions or verifications that are required.

6. Test Execution

The scripts developed during the design phase are now executed in this phase. Execution can be performed using the automation testing tool or the test management tool, which will, in turn, invoke the test automation tool. You should start the execution of your test scripts as early as possible. This is what the Shift Left Testing approach also suggests.

In contrast to traditional models like the Waterfall Model, where testing comes into the picture at the very end of the cycle, the Shift Left Testing approach suggests moving the Testing activities “Left” or rather “earlier” in the development cycle. Thus, it involves the testers much earlier in the software development life cycle. The earlier the testers are involved, the more bugs you find, and as a result, you have a better quality product.

Also readHow To Implement Shift Left Testing Approach

7. Maintain, Analyze and report

In this phase of automation testing, testing is carried out in order to determine whether the newly added functionalities are working fine or not. Maintenance and up-gradation of test suites are carried out in order to improve the effectiveness of automation scripts with each successive release cycle.

Many firms even use this phase for Shift-Right Testing. Shift-Right testing, or rather Testing In Production, happens after the software is deployed in production environments. This is mainly done in order to ensure the correct performance, stability, and usability of the application in the production environment.

Also, examine the test findings to find any errors or irregularities. Create thorough reports that offer information on the test coverage, pass/fail status, and any flaws discovered. Making knowledgeable choices concerning the suitability of the application is aided by this study.

Different Approaches to Automation Testing

It is equally important to understand different approaches to automation testing while performing automation testing, therefore, I’ve added a separate section in this automation testing tutorial for your better understanding. Here are the three main approaches that you can consider while performing automation testing.

  1. Code-Driven Testing
  2. Graphical User Interface Testing
  3. Framework Approach

Code-Driven Testing

This testing approach is a popular method in agile software development. Here, the focus is mainly on test case execution to determine if different sections of code are performing as per expectations or not.

The idea behind code-driven testing is to use a programming language to write the unit test instead of using an external tool that provides a testing framework. The advantages are that you have full power at your disposal to create whatever tests you want, and you don’t have to deal with an external tool. The disadvantage is that it is harder to set up and run tests, so it can be more difficult to get people to do it regularly.

Graphical User Interface Testing

With the increasing complexity of software and its graphical interfaces, the need for formal GUI testing has increased dramatically. The testing process can be categorized into two main types: unit testing and functional testing.

Unit testing, which is most often driven by developers, involves a detailed analysis of each component of the application to ensure that it is operating correctly in isolation. Functional testing, on the other hand, determines whether or not all components of the application can be used as expected by the end user. This phase of GUI testing is usually performed by quality assurance analysts who are more familiar with how users interact with the application.

Test Automation Framework

A framework is a set of guidelines that help in maintaining test consistency and test structure. It also helps in achieving the maintainability, scalability, and reusability of the code across test cases.

There are four major kinds of frameworks used in automation testing:

  1. Data-Driven Framework – These frameworks are focused on separating the logic of test cases and the test data separately. Here the data is treated as an input to the test script logic. Each data set can be treated as a separate test case.
     
    A data-driven framework is a test automation framework that stores keywords and locators of elements into an external file, such as an XML file. This makes it easier for testers to build test cases because it does not require the use of object repositories.
     
    Data-driven frameworks are often used with keyword-driven frameworks. Keywords are stored in a data file and then placed into a function library. The keywords may be written manually or generated via recording. Tests are created in the data file, which can be edited by testers without programming knowledge. The test data for each keyword is stored in the same row as the keyword, making it easy to change.
  2.  

  3. Keyword-Driven Framework – A keyword-driven framework is essentially a data-driven framework that is limited to accepting inputs only from an excel data source. In this type of framework, test case logic resides in a database table and is linked to one or more related tables that contain the test data. Each logical operation of the application under test is defined as a keyword, which represents some action on the application under test. The keywords are then mapped to a subroutine, which implements the functionality of the keyword and performs the desired action on the application.
     
    The main advantage of this type of framework is that it does not require any programming skills because all the required operations can be performed using keywords. Therefore, anyone (even nonprogrammers) can create and execute test cases using this approach. However, this framework limits itself to operations that can be performed using existing keywords; no new keywords can be created because they would require programming knowledge.
  4.  

  5. Modular Testing Framework – Modular Testing Framework is a way to test a piece of software in isolation. Each module is tested with the same testing framework so that testing multiple modules can be done with a single line of code.
     
    The framework is composed of two main components: Test Cases and Test Suite. A Test Case is an object that defines a series of steps or actions to be performed. The Test Suite is simply an object that contains a collection of Test Cases.
     
    When the Test Suite is executed, it will execute each Test Case using a Test Runner object that can perform assertions on the results produced by executing the individual Test Cases.
  6.  

  7. Hybrid Testing Framework – Hybrid Driven Framework is a mix of both the Data-Driven and Keyword-Driven Frameworks. In this case, both keywords, as well as the test data, are externalized.
     
    A hybrid testing framework combines the strengths of two approaches, using features of both to achieve the best of both worlds. It can be especially good at handling complex, difficult-to-test situations, and requirements.

Also readTDD vs BDD: Choosing The Suitable Framework

Popular Test Automation Frameworks

Now that we have learned the basics about test automation, let’s see some of the popular test automation frameworks which are being widely used.

popular test automation frameworks

Source

  • Selenium – Selenium is a popular test automation framework used to validate web applications across different browsers and platforms.
  • Cypress – Cypress is a JavaScript test automation solution used for web automation. It enables teams to create web test automation scripts.
  • TestNG – TestNG is a powerful test automation framework for Java. It is inspired by JUnit and NUnit. It can be used to cover a wider range of test categories: unit, functional, end-to-end, integration, etc.
  • WebDriverIO – WebDriverIO is an open-source testing utility for nodejs. It allows you to run Selenium tests written in JS on multiple browsers and platforms.
  • Pytest – pytest is a testing framework based on python. It’s often considered to be the de-facto standard when it comes to writing unit tests for python code.
  • NUnit – The NUnit Framework is a unit testing framework for all .NET languages.
  • PHPUnit – PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.
  • Cucumber – Cucumber is an open-source tool that supports Behavior Driven Development(BDD) frameworks. Cucumber enables you to write test cases that anyone can easily understand regardless of their technical knowledge.

These were some of the popular test automation frameworks I have come across for different languages. However, the list doesn’t end here. There are a lot of other test automation frameworks also available in the market. You can check them and select one that best suits your overall requirements.

Also readCypress Vs Selenium: How To Pick The Right Testing Tool

Example of Test Automation

Let us now see a basic test automation example. In this case, we will automate a web page making use of the Selenium framework and LambdaTest.

Selenium is an open-source framework for cross-browser and cross-platform testing of web applications. It is a suite that allows automated tests of websites and web applications in different browsers on different platforms using any programming language of your choice.

Cloud testing tools like LambdaTest offer a cloud Selenium Grid that lets you run parallel tests on an online browser farm of 3000+ browsers and operating systems. All you need to do is instantiate the remote Selenium WebDriver instead of the local Selenium WebDriver.

Here’s a quick video on performing Selenium automation testing on the LambdaTest platform.

You can also Subscribe to the LambdaTest YouTube Channel and stay updated with the latest tutorials around automated browser testing, Selenium testing, CI/CD, and more.

With LambdaTest, you don’t have to worry about downloading and configuring hundreds of browsers on your machine, as they are readily available on the online Selenium Grid. Instead, all you need to do is register on LambdaTest for free, claim your 100 free automation testing minutes, and run Selenium IDE tests on cloud.

Now that we have covered the basics of cloud Selenium Grid let’s implement a sample example using LambdaTest Selenium Grid.

Problem Statement

In the below example, I am running the same test case on Chrome (latest) + Windows 10 combination.

  1. Launch Chrome browser on Windows 10.
  2. Open LambdaTest sign up page.
  3. Click on the Sign In button.
  4. Close the web browser.

Implementation

FirstTestScriptUsingSeleniumGrid.java

GitHub

You will need the below pom.xml for importing the necessary dependencies.

pom.xml

And the below testng.xml file will be needed for running the test case.

testng.xml

GitHub

Code Walkthrough

  • Global Variables: As tests have to be run on LambdaTest cloud Selenium Grid, we would be using the below-shown variables.
  • Here, you can populate the values for your corresponding username and access key, which can be collected by logging into your LambdaTest Profile Section. However, the gridURL will remain the same.

    gridURL

  • @BeforeTest(Setup Method): In Selenium, the RemoteWebDriver class implements the WebDriver interface to execute test scripts through the Selenium RemoteWebDriver server on a remote machine.
     
    The @BeforeTest annotation in TestNG is used to execute a set of statements before running a test suite. This method can be used for initializing the resources required for your test case.

    The below-imported class will help you in using the RemoteWebDriver class.

  • imported class will help you in using the RemoteWebDriver class

    Here, I have used the LambdaTest Desired Capabilities Generator and have set the necessary capabilities of browser name, version, platform, etc.

    capabilities of browser name, version, platform

  • @Test(firstTestCase): In the test case, I opened the LambdaTest sign up page in the Chrome browser using the driver.get() statement. The findElement method in Selenium is used for locating the SignIn WebElement.
     
    Here, I have used XPath in Selenium for locating the ‘Sign In’ button. To investigate the XPath of any element, you can simply right-click on it and click on Inspect. You will be able to spot the locator in the Elements tab. The click method in Selenium is used for clicking on the Sign In button.
  • click method in Selenium

  • @AfterTest: In the AfterTest method, close the browser using the driver.close() method.
  • AfterTest

Execution

You will see the below output once you run the testng.xml file.

run the testng.xml file

Once the tests are completed, Log on to LambdaTest Automation Dashboard to check the status of the test execution on LambdaTest.

You can also access the report on LambdaTest Analytics Dashboard. The dashboard shows all the details and metrics related to your tests.

Test Summary gives you a high-level overview of your test performance. It shows how many of your previous tests passed and failed and how effective each team member was in running their tests. Don’t forget to check out Test Overview for interactive visualization of how your tests are performing over time.

Conclusion

In this automation testing tutorial, we got to know what is automation testing, the differences between manual and automation testing, the need for automation testing, and a few approaches to do the same. We also saw which test cases should be automated and implemented our first automation test script with Selenium.

Investment in automation testing is essential to maintain the efficiency and effectiveness of the software development process. It is important to estimate the return on investment (ROI) of automation testing, especially when the company has a tight budget and cannot afford all the requested projects.

I hope this article helps you in taking the first step towards your automation testing journey and, as a result, helps in achieving a better quality of your software. Check out our hub on test automation metrics to examine various metrics for measuring success, the strategies for metric implementation, and its challenges involed.

Also, read about the distinctions between Manual Testing v/s Automation Testing in this Comprehensive Guide.

Happy Testing 🙂

Frequently Asked Questions (FAQs)

What is basics of automation testing?

Automation testing is a Test Automation technique that uses special software tools to control the execution of tests and then compares actual test results with predicted or expected results. Automation testing can execute test cases automatically, but it also requires a tester to evaluate and analyze the test results.

What are the current trends in automation testing?

The current trends in automation testing have been changing from time to time. The most common and effective automation tools used today are the ones that use a combination of expert systems, machine learning, and artificial intelligence.

Which automation testing tool is in demand 2022?

Selenium and Appium are the two most popular automation testing tools, which will remain in demand in 2022.

What are automation tools?

Automation tools are software applications designed to streamline and simplify repetitive tasks, reducing manual effort and increasing efficiency. These tools employ various techniques, such as robotic process automation (RPA) and artificial intelligence (AI), to automate workflows and optimize business processes. They are invaluable assets in enhancing productivity and achieving higher operational effectiveness.

What are the 4 types of automation?

The four types of automation commonly recognized are fixed automation, programmable automation, flexible automation, and intelligent automation. Fixed automation involves the use of specialized machinery for repetitive tasks, while programmable automation allows for customization through computer programming. Flexible automation combines programmability and versatility, and intelligent automation incorporates advanced technologies like AI and machine learning to optimize processes.

What are automation skills?

Automation skills refer to the ability to design, develop, and implement automated systems and processes that streamline and optimize workflows. These skills encompass programming, scripting, data analysis, and proficiency in relevant tools and technologies. Automation skills empower professionals to enhance productivity, reduce errors, and drive efficiency in various industries.

What is automation coding?

Automation coding refers to the process of developing computer programs or scripts that enable the automatic execution of tasks or processes. It involves writing code to control software, systems, or robots, eliminating the need for manual intervention. Automation coding streamlines operations, enhances efficiency, and reduces human error, thereby improving productivity in various industries.

Is it easy to learn automation?

Learning automation can be a challenging yet rewarding endeavor. It requires a solid understanding of programming languages, frameworks, and tools. However, with dedication, persistence, and a strong foundation in software development, one can acquire the necessary skills. Continuous learning and practice are key to mastering automation.

What is the main purpose of automation testing?

Automation testing serves as an essential practice in software development, primarily aimed at enhancing efficiency, reliability, and accuracy. By automating repetitive and time-consuming test cases, it enables faster feedback cycles, reduces human error, and facilitates regression testing. The main purpose of automation testing is to optimize software quality and accelerate the delivery process.

Author Profile Author Profile Author Profile

Author’s Profile

Ria Dayal

A Senior Quality Engineer By Profession, an automation enthusiast and loves to anchor. Her expertise revolves around Selenium, Java, Rest Assured, and Jenkins. Shell scripting too interests her a lot. Ria enjoys reading novels and writing is her comfort zone.

Blogs: 9



linkedintwitter

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free