Why Test Automation? An Introduction to Selenium!

“As ironic as it seems, the challenge of a QA Engineer is to test as little as possible. Test less, but test smarter!”

So, let me ask you people a question: Is the above statement even possible with reference to Manual Testing? Is it?

Okay, I heard you saying, Not Possible :)

Then, what else could be done? Is Test Automation the alternative? Let us find the answer to this question!

Why Automation Testing?

  • We already know from the previous blog that Manual testing is a software testing technique performed by QA Professional sitting in front of a computer, trying various usage and input combinations, comparing the results to the expected behaviour and recording the observations.
  • Manual tests are often repeated during the development cycle process.

But don’t you think this process is quite tedious & very much prone to human errors?

And here Test Automation comes into the picture!

  • Automation Testing or Test Automation is a software testing technique using automated software testing tools with a goal of reducing the testing efforts & delivering affordable products in less time.
  • It helps in building better quality software with less effort.
  • In Automation Testing, there is a set of predefined actions. The automated testing tool compares the results to the expected behaviour and reports the success or failure of these tests to the Test Engineer.
  • These tests can be easily repeated or modified to perform the tasks which are impossible with manual testing. Hence, making it an essential component of successful development projects.
  • Automation Testing requires lesser investment in Human Resources & it’s more accurate.
  • It vastly increases the Test Coverage.

Now, we know why Automation Testing is needed! But we would also need a tool for it, right? So, let us see what is exactly meant by the term ‘Testing Tool’.

Testing Tools:

  • Testing Tools are the products that support the test activities such as planning, requirement gathering, build creation, test execution, defect logging and test analysis. 
  • QA Testing tools are categorized into three main categories:
  1. Open-Source tools: The tools which are free of cost and the source code is openly published for use are called as Open-Source tools.
  2. Commercial tools: Commercial tools are the software which is produced for sale or to serve commercial purposes.
  3. Custom tools: The testing tool which is developed to meet the requirement of a certain project is known as Custom Tool.

Again, there are various software testing tools available in the market, and with the plethora of choices, it becomes quite difficult to select the one. But, selection of Testing Tool mainly depends on the following factors:

  1. Size of the application
  2. Test data
  3. Complexity & Stability of the application
  4. Most importantly, Technical Feasibility

If I am right, till now you might have got confused about which Software Testing Tool you should consider???? Let me try to clear your confusion in one simple sentence! So, there are thousands of animals in the jungle but who is the king? THE LION!

Similarly, there are plenty of Testing tools out there but SELENIUM IS THE KING OF ALL THE TESTING TOOLS!

SELENIUM:

  • Selenium is a suite of software tools to automate web browsers.
  • It is an open Source Automation Testing tool ie; no license is required.
  • Selenium supports multiple browsers –
    Chrome, Firefox, Internet Explorer, Safari.
  • Selenium works with Multiple Platforms-
    Windows, Linux, MAC, Android.
  • It supports most of the programming languages, Java, Python, C#, Javascript, Ruby, PHP to mention a few.
  • It offers the support for parallel test execution that reduces the time taken in executing parallel tests.
  • Selenium provides support for many frameworks such as TestNG, JUnit, Cucumber, NUnit.

One of the best features of Selenium is: It supports almost every type of testing including Sanity Testing, Regression Testing, GUI Testing, Usability Testing and many more!

Components of Selenium Suite:

  1. Selenium IDE:
  • Selenium IDE stands for Selenium Integrated Development Environment.
  • It is a record and playback automation tool using which Web Applications can be automated.
  • Selenium IDE has limited scope and the generated test scripts are not very robust and portable.

2. Selenium RC:

  • It stands for Selenium Remote Control.
  • It is officially disapproved by Selenium.
  • It had many limitations like it was slow.
  • In Selenium RC, before executing the test scripts, the server was required to be started.

3. Selenium Webdriver:

  • Selenium WebDriver is the improved version/successor of Selenium RC and is by far the most important component of Selenium Suite.
  • It provides different drivers for different browsers.
  • It supports multiple programming languages.
  • Selenium Webdriver is purely object-oriented and supports all the major browsers.

4. Selenium Grid:

  • It helps in the distributed running of Selenium in parallel across multiple remote machines.
  • It has a hub and multiple nodes.
  • The nodes are connected to a central hub which acts as a server and controls the whole test execution.

** Among all the four tools discussed above, you can easily figure out that Selenium Webdriver is the best one to get started with Automation!

Point to Note: Selenium is an open-source test automation suite whereas Selenium Webdriver is a tool. You can understand this with the following logic:

Selenium is like a parent having four kids, namely Selenium IDE, Selenium RC, Selenium Webdriver and Selenium Grid! Hope now it’s clear to you 🙂

Selenium Webdriver Architecture and Workflow:

Now let us try to understand the Architecture of Selenium Webdriver.

  • First of all, when the Test is triggered, complete Selenium code (Client) {which we will learn to write soon!} will be converted to JSON format.
  • The Generated JSON is sent to the Browser Driver (Server) through HTTP Protocol.
  • Note: Each browser contains a separate browser driver
  • Browser drivers communicate with its respective browser and execute the commands by interpreting JSON which it received on the browser.
  • Browser Driver receives responses back from the browser and it sends JSON response back to Client.

For a better understanding of the Workflow of Selenium Webdriver, consider the following diagram:

So now we are very clear with the Selenium basics and it’s the correct time to get into some real stuff!

Selenium with Java

  • Selenium supports various programming languages. Of course, you can use any of them like Python, Javascript, C# and many more! But Selenium + Java combination is the favourite among QA Engineers.
  • The various reasons behind using Java for Selenium are as follows:
  1. Java is around since ages, hence there is an abundance of easily available frameworks, plugins, APIs and libraries that supports Java for test automation.
  2. Nearly 77% of Selenium Automation Engineers are using Java which makes the knowledge sharing quick and easy.
  3. Java has a huge repository of references as it’s quite popular in the IT Industry.
  4. The Java IDEs provide a lot of feedback on errors that we might face while coding or writing the test scripts.

Hope I’m able to make you understand the popularity behind the Selenium + Java Combination 🙂

Now you must be wondering, how much Java we should know to use it with Selenium? So, in the next article, we will start our learning with the Core Java that we would be using further for writing the test scripts and we’ll also study in detail about Selenium Webdriver right from the installation to automating the Web Elements and finally executing the Test Scripts!

So, for all of that and more, see you in the next blog 🙂