selenium-based-automation-part2

Selenium Based Automated Testing (Part 2 Of Series)

Now that we understood the benefits of Automated Testing(in Part 1 of Series, “Shifting towards Automated Testing for Continuous Delivery“), and to implement the tool that many of us would consider is open source; unarguably, Selenium.

Selenium

Selenium is an open-source Automated Testing tool which provides a single interface to help you write test scripts in programming languages like Java, JavaScript, Python, Ruby, etc. to test web-based applications.

 Selenium has 4 components:

  • Selenium IDE
  • Selenium RC
  • Selenium WebDriver
  • Selenium Grid

Selenium image by Testsigma

Selenium IDE

Selenium Integrated Development Environment is a Chrome and Firefox plugin that can log interactions in the browser and generate its code in programming languages mentioned above, as well as Selenese which is Selenium’s own scripting language (yes, Selenium has its own scripting language!).

Selenium RC

Selenium Remote Control, also known as Selenium 1, was the first tool of Selenium Suite. Selenium RC is a server, written in Java, that accepts commands for the browser via HTTP. All the browsers which support JavaScript can be automated using Selenium RC.

In Selenium RC there is a manual process called Selenium Server which acts as a middleman between the code and the browser, and it is mandatory to start before the execution. The commands (API’s) are sent to Server which interprets the command and converts it into JavaScript and then JavaScript is injected to the browser. After that, the browser executes the JavaScript and responds to a Server, which again interprets the command and returns the code to the respective language.


Selenium RC Image by Testsigma

Selenium WebDriver

Selenium WebDriver, also known as a Selenium 2.0, is the most important tool of the Selenium Suite. Selenium WebDriver formed as a Selenium RC upgrade, and it does not require any manual process like Selenium Server, instead, there is direct communication between code and browser.

 
Selenium WebDriver consists of:


  • API – Application Programming Interface. Ports test scripts written in Ruby, Java, Python, etc. to Selenese (Selenium’s own scripting language), through bindings.
  •  
  • Library houses the API and language-specific bindings. Although plenty of third-party bindings exist to support different programming languages, the core client-side bindings supported by the main project are: Selenium Java (as selenium jar files), Selenium Ruby, Selenium dotnet (or Selenium C#, available as .dll files), Selenium Python, and Selenium JavaScript (Node).
  •  
  • Driver – Executable module that opens up a browser instance and runs the test script.
  •  
  • Framework – Support libraries for integration with natural or programming language test frameworks, like Selenium with Cucumber or Selenium with TestNG.

The way Selenium WebDriver works:

The WebDriver protocol has a local end named client which sends the commands (test scripts) to a browser-specific driver. The driver then executes these commands on its browser instance. So, if the test script calls for execution on Chrome and Firefox, the ChromeDriver will execute the test on Chrome; the GeckoDriver will execute the test on Firefox.

Note: Test scripts execute only when the WebDriver’s client and browser/driver are connected. It doesn’t have to be on the same device. However, to enable test execution on multiple remote drivers, you need RemoteWebDriver and the Grid.

Selenium Grid

Selenium Grid is the last component of the Selenium Suite and it is used for the parallel testing or distributive testing. It allows us to execute test scripts on different machines at the same time.

The Architecture of Selenium Grid

In Grid one of the systems is created as Hub. Hub works as a central point controlling all the nodes, it accepts access requests from WebDriver client. Nodes are an actual machine on which execution is done and contains a native OS, browsers and RemoteWebDriver.

 
Credits: me 🙂

The way Selenium Grid works

WebDriver-client executes the test on a faraway device through RemoteWebDriver. RemoteWebDriver is like a regular WebDriver, except its two components are the Client (your test script) and Server (a Java servlet that actually executes the test on the remote device).

In your test script, you define ‘desired capabilities’ (device, platform, browser, etc.) of the node where the test will execute. The Hub receives test script, runs through the registered nodes to find the one that matches the desired capabilities, and assigns the test to it for the execution.


Try Testsigma which gives you all the advantages of Testsigma, with very less effort. Automate your tests faster using plain English!



Advantages and Disadvantages of Selenium

Advantages of Selenium

  • Selenium is an open source software, anybody can download the source code and use it, modify the source code according to company requirements, but selling modified code is not allowed.
  • Selenium supports various programming languages to write test scripts – Java, C#, Perl, Python, Ruby and PHP. Although it supports all mentioned languages, only one language can be used at the time. Most of the Selenium Testers use Java (nearly 70%).
  • Selenium supports all currently available operating systems (Mac, Windows and Linux).
  • Selenium supports various Browsers (Firefox, Google Chrome, Internet Explorer, Safari, etc.)
  • Using Selenium Grid, we are able to execute tests in parallel, so that we can reduce the test execution time.
  • Selenium integrates well with popular tools such as SauceLabs, Selenium Grid, Extent, JUnit, TestNG, and others.
  • Selenium is backed by a vast community of developers and testers who actively contribute to the tool and documentation.
  • Reusability and maintainability are much better in Java than in JavaScript if you apply correct patterns.

Disadvantages of Selenium

  • Since Selenium is an open source software, nobody providing reliable technical support.
  • With Selenium, we can automate Computer Web Applications and Mobile Web Applications, but we cannot automate Computer Desktop Applications, Mobile Native Applications and Mobile Hybrid Applications.
  • Selenium WebDriver does not have built-in Results Report facility, we need to use JUnit or TestNG Testing Framework to generate Test Reports.
  • Selenium demands higher-level technical skills, such as programming, from QA team members.
  • There is no support for running tests in parallel on a single computer.
  • Selenium + TestNG/JUnit is not the complete, comprehensive solutions to fully automate testing of your web application. You need different libraries (POI API, GSON, Extent Reports) to make it a complete solution for a testing framework. Managing multiple dependencies is difficult and requires extra maintenance work that everyone wants to avoid. A good dependency management tool such as Maven, Gradle or NPR can make this task easier.
  • With Selenium Grid you can execute tests in parallel, as is mentioned above. However, it is not always feasible to set up and manage test machines since the requirements for devices vary with projects.

Testsigma is built to address all the challenges in Selenium, Signup for a free trial.



As you could see, Selenium has pros and cons and depending on your type of software you should consider which approach is the best. After considering all, maybe Automated Testing would not be the best approach, and that is where Scriptless Automation Testing advent.

We will tell something more about the challenges in Selenium based Automated testing, so you can better understand the difference between Automated Testing and Scriptless Test Automation.

Challenges involved in Automated Testing

  • Lack of quicker feedback: Scripts are written after the application is built and stabilized. Early feedback, which is essential for the reduction of the cost of quality in Agile development, is seldom available. Read more on the importance of Shift Left Testing.
  •  
  • Substantial upfront investment: Huge upfront investments are necessary due to complex scripting environments and tools, and also for test infrastructure. Hence, we would need to hire and train skilled resources. The article Overcoming The Ramp-up Delay, Cost and Resources Required To Automate Testing explains about the test automation ecosystem.
  •  
  • Change of focus: The prime objective of the testing team has moved from testing the functionality of the application to the technical development and execution of scripts.

In conclusion,  the key holdups in adopting traditional QA methods are the issues faced by functional and business teams in understanding automation scripts. Additional effort is required to make them available to non-technical users, leading to reduced collaboration between the functional specialists and automation teams.

One of the solutions to maximize the scalability of Automated Testing is Scriptless Test Automation. Scriptless Test Automation enables QA Engineer to automate test cases without coding, and any knowledge of it. It helps to achieve faster results and reduces the time expanded to understanding the code.


In our next article, we will introduce you to Scriptless Test Automation and its tools, with an accent to Testsigma’s approach and write about it in detail.

Until then, sign up for a free trial of Testsigma, Scriptless Test Automation tool powered by NLP! Start writing complex automated tests in simple English.


Check out what’s in store!