Do you want to know- What is Selenium framework? and What are Selenium Framework Types?
Great!! In this tutorial, we will learn about the Selenium Tool and Automation Library. In simple words we will understand, What is Selenium used for and How can a beginner start learning Selenium from scratch? Also, we will see a lot of common myths and doubts of Selenium Framework in this post.
So, Let’s get started with our Selenium Framework Mastery Series with some frequently asked important Selenium questions – What is Selenium framework and Why to use Selenium ?
What is Selenium used for ?
First of all, Selenium is a suite of projects. It means, Selenium project contents a couple of independent sub-projects / sub-frameworks / libraries inside it. So, generally we call Selenium as Selenium Library, or Selenium Framework as well.
In case, If you are not aware about – What is a software library? Then, you can think it as, a piece of code written by a person or team, that solves some critical and common problems.
Selenium library basically automates Web browsers. That means, almost any task that you can think to do in your web browser (such as Chrome / Firefox etc.), all those tasks can easily be automated with help of Selenium Libraries.
Now, we know what is selenium framework? Let’s understand with a real life example- Why to use Selenium?
To understand the usage of Selenium framework, let’s pick a simple day-to-day example –
Suppose, You need to send an email to a list of people. So, you are opening any browser (eg. Chrome) in your Windows, Linux or Mac machine, then login into Gmail, and then you will compose and send an email to the people. This simple emailing task can easily be automated with help of Selenium framework and any programming language.
To automate the above task, You just need to write a few lines of code using Selenium Library in a programming language, and it will exactly do the same as above, similarly to what you were doing manually. This is also known as Automation, and a key part of Automation Testers day to day activities.
In Short –
- Selenium is a suite of projects / libraries used to automate web browsers.
- Selenium is freely available to use.
- Selenium supports automation of all the major browsers (eg. Chrome, Firefox, Safari, Edge, etc.) using different programming languages (eg. Java, Python etc.)
- Selenium is a high demand web automation library in the job market, with combination of Java or Python programming language.
So, this was all about usage of Selenium framework. Now, Let’s jump into other questions related to Selenium framework.
Selenium framework types? Which Selenium framework is mostly used?
Selenium is basically a suite of projects or pack of frameworks. So, let’s dig deeper into that and understand all the Selenium framework types and which Selenium framework is mostly used?
Till this time, April 2023, we have 3 types of Selenium framework available –
# | Selenium Frameworks | Framework Basic Usage |
1. | Selenium WebDriver | Used for Website automation and Web application automation. |
2. | Selenium IDE | It is available in form of browser extensions (Chrome and Firefox extension). It records browser actions and plays it again and again. |
3. | Selenium Grid | Used for running test cases / selenium scripts in different machines (Computers, Smart phones) across different platforms (macOS, Linux, Windows, Android, iOS) on multiple browsers (Chrome, Firefox, Safari, etc). |
Selenium framework contains these 3 tools / libraries inside the suite. Now, it is upto you, what is your requirement and number of resources, to get started with any of the above Selenium Framework.
- Selenium WebDriver :
In case, If you are beginning with desktop or mobile website test automation, then you are going to be using WebDriver APIs. The Selenium WebDriver library uses different browser binary files (provided by browser vendors, such as: Google Chrome provided ChromeDriver binary file, Mozilla provides Firefox binary file) to control the actual browser and run test case on the web browser.
No browser company allows Selenium to run its automation script by directly communicating with their browsers, that’s why, browser companies provide a mediator API / binary file which takes commands from Selenium and passed it further to actual browser, and vice versa.
Once you”ll run the code / script written with Selenium WebDriver Framework, it will look like, a real user is operating the browser. Since, WebDriver does not require its API to be compiled with application code, that’s why it can be included anywhere. - Selenium IDE :
Selenium IDE (stands for Selenium Integrated Development Environment) is the tool you use to develop your Selenium test cases. To use Selenium IDE, you need to install it’s extension in your Chrome and Firefox browser. It is generally the most efficient and easiest way to develop test cases.
How Selenium IDE works is – It records the users’ actions in the browser, using existing Selenium commands, with parameters defined by the context of that element. Now, the recorded steps can be played multiple times to verify whether the functionality is working as it was running previously or not. - Selenium Grid :
Selenium Grid is a powerful framework which allows you to run your test scripts in different machines across different platforms on different browser. How Selenium Grid works is, The overall control of triggering the test cases is on the local end, and when the test cases are triggered, they are automatically executed by the remote end.
After the development of the WebDriver tests, you may face the need to run your tests on multiple browsers and operating system combinations. This is where Selenium Grid comes into the picture.
Now, if you’ll ask, which Selenium framework is mostly used by the companies, then as per my experience and current market trends of automation frameworks, most of the time Selenium WebDriver is the first choice to write automation suites and then in complex scenarios Selenium Grid is also being used quiet often.
Selenium Framework example program with explanation?
If you are absolute beginner in Selenium Framework, then you might not understand the below script, but I’ve provided a simple Selenium Framework example program in Java programming language. This script will simply look like below program –
Selenium Framework Sample Program –
package com.logicalduniya.selenium.programs;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class FirstSeleniumProgram {
public static void main(String[] args) {
WebDriver driver = null;
try {
// Step 1: Setting up the firefox binary file to communicate with Firefox browser -
WebDriverManager.firefoxdriver().setup();
driver = new FirefoxDriver();
// Step 2: Visiting to Google.com -
driver.get("https://google.com");
// Step 3: Finding the search input field and sending our search term -
driver.findElement(By.name("q"))
.sendKeys("Selenium Framework Tutorial by LogicalDuniya");
Thread.sleep(3000);
// Step 4: Hitting Keyboard key = RETURN (for mac) OR key = ENTER (for windows) to get search results -
driver.findElement(By.name("q"))
.sendKeys(Keys.RETURN);
// Hold the UI for 5 seconds to view the screen -
Thread.sleep(5000);
System.out.println("---- Search Complete ----");
} catch (InterruptedException e) {
System.out.println("----- Something went wrong -----");
e.printStackTrace();
}finally {
// Step 5: Closing the window opened by the script and quitting the driver -
driver.close();
driver.quit();
System.out.println("----- Thank you for visiting - LogicalDuniya.com -----");
}
}
}
Explanations –
Here’s the detailed explanation of above Selenium sample script with Java programming language :
Step 1) Set up the Firefox binary file, that will communicate with Firefox browser,
Step 2) Launch the Google.com using Firefox WebDriver
.
Step 3) Find the search input field and sending our search term,
Step 4) Hit Keyboard key = RETURN (for mac) OR key = ENTER (for windows) to get search results,
Step 5) Close the browser window opened by the script and quit the driver.
So, the above are the 5 steps, following which our script will perform the steps using automation.
What is the Selenium Framework Design?
When working on frequently testing a large and complex application, it is really important to properly organize, maintain and improve the performance of automated test cases. If we focus on one single parameter, then we might achieve this goal, and that one parameter is – Designing such a Selenium Automation Framework, which should have below qualities –
- Highly Efficient Framework- That enables it to reuse of components or code.
- Structured Automation Framework- That ensures uniformity of design across multiple test scripts to reduce dependency on individual test-cases.
- Completely Reliable – That can help to find application’s issues and to detect bugs and delivers proper root-cause analysis with minimum human intervention.
- Less Dependency – That framework should not be dependent on a particular plugin / tool / any 3rd party dependency.
- Fully Automated – That framework should ensure an uninterrupted automated testing process with little man-power involvement.
So, it is essential to use a framework for automation testing as it specifically improves the Quality Assurance teamβs efficiency and testing speed. And, different Selenium Frameworks can help us to build such a robust and high performing automation framework from scratch.
Selenium framework creation? History of Selenium framework?
- The story of Selenium Framework starts in 2004 at ThoughtWorks in Chicago, with Jason Huggins building the Core mode as “JavaScriptTestRunner” for the testing of an internal Time and Expenses application (Python, Plone).
Automation testing of any mobile or Web applications is core to ThoughtWorks’ style, given the Agile leanings of this consultancy. He got help from a few of his colleagues – Paul Gross and Jie Tina Wang. - After a decent library development, Jason started demoing the test tool to various colleagues. Many were excited about its immediate and intuitive visual feedback, as well as its potential to grow as a reusable testing framework for other web applications.
- Soon after in 2004 fellow ThoughtWorker Paul Hammant saw the demo, and started discussions about the open sourcing of Selenium, as well as defining a ‘driven’ mode of Selenium where you’d get to use Selenium over the wire from a language of your choice, that would get around the ‘same origin policy’.
Other (then) colleagues, Aslak Hellesoy and Mike Melia, experimented with different ideas for the ‘server’ piece, including page rewriting to get around the same origin policy. Paul wrote the original server piece in Java programming language, and Aslak and Obie Fernandez ported that the client driver to Ruby, setting the foundation for drivers in yet more languages - ThoughtWorkers in various offices around the world picked up Selenium for commercial projects, and contributed back to Selenium from the lessons learned on these projects. Mike Williams, Darrell Deboer, and Darren Cotterill all helped with the increasing the capabilities and the robustness of it.
So, as a summary, you can remember as- Jason Huggins is the founder of Selenium Framework.
Which programming language is used in Selenium?
The best thing regarding Selenium Framework is that, this web automation library can easily be use with different types of programming languages. We can use any of these programming languages to write automation scripts with Selenium-
- Java
- Python
- C# / C-Sharp
- Ruby
- JavaScript
- Kotlin
So, whether you are a Java developer, Python developer or C# guy, you can easily use Selenium to automate your browser based tasks.
What are the four types of Selenium?
As we already know, Selenium framework is basically a suite of projects, under which different Selenium projects are available for different – different usage. Selenium is not just one tool or API, but it contains these many tools, with a few specific purposes –
1) Selenium WebDriver.
2) Selenium IDE.
3) Selenium Grid.4) Selenium RC. (Deprecated now / Out from market)
Selenium WebDriver :
You can use the Selenium WebDriver API / Library, to write test cases for desktop websites and mobile websites. To use Selenium WebDriver, all you need is to write Selenium script (in any programming language) and a browser driver binary file (to communicate with browsers). Now, when you’ll execute your Selenium script, it will execute as if a real user is operating the browser.
Selenium IDE :
Selenium IDE is another core part of Selenium Framework suite. Selenium IDE is basically a browser extension which can be used to record and playback the recorded UI steps or Test cases.
This is an open source record and playback test automation tool for the web application testing. To use the Selenium IDE, you need to use Chrome / Firefox.
In chrome, they have provided a chrome extension and after installation of this Selenium IDE extension you can record the manual testing steps.
Selenium Grid :
Selenium Grid helps when you want to run your test cases in parallel across multiple machines. This increases the speed of testing and allows us to generate the results much faster.
Aim of Selenium Grid :
1. Provide a super easy way to run our scripts or automated test cases in parallel on multiple machines.
2. Allow automation testing on different browser versions.
3. Enable cross platform testing (that is, running same test case on Windows, Mac, Linux, other operating systems).
Selenium RC (Deprecated now / Out from market)
Selenium RC was the main part of Selenium Framework until Selenium 2 came with WebDriver.
Selenium RC had 2 main components :
- The Selenium Server –
It was responsible for launching and killing the browsers, interpreting and running some commands that got passed from the test program, and acts as an HTTP proxy, intercepting and verifying HTTP messages passed between the browser and the AUT. - Client Libraries –
It was responsible to provide the interface between each programming language and the Selenium RC Server. Using this component, we as an Automation Tester, write scripts that interacts with the actual Selenium RC Server.
Why to use Selenium library in Software Testing? Benefits of using Selenium?
I believe, now you have basic idea about – Why to use Selenium library in QA / Software Testing related tasks? To reiterate, the benefits of Selenium framework, here are some key points to remember –
- Language and Framework Support
- Open Source Availability
- Multi-Browser Support
- Multi-OS Support – Supports Across Various Operating Systems
- Ease Of Implementation
- Re-usability and Integrations
- Flexibility
- Parallel Test Execution and Faster Go-to-Market
- Zero and Less Additional Hardware Usage
- Easy to Learn and Use
- Constant Updates and Community Support
Bonus Question = How do I start learning Selenium?
If you want to learn Selenium Framework step-by-step from beginner to advanced level, then check this series of Simple Selenium Tutorials from beginning to advanced level. In this series, we have covered all basic concepts, interview level questions, best practices used in top product companies such as Google, Amazon, Apple and Microsoft.
(ToDo : Add Live links here..)
So, what are you waiting for, Start learning Selenium Tutorial from here …
Conclusion –
In this Selenium framework beginner tutorial, we understood – why is Selenium a high demanding open-source web-based automation tool. We also know, Which Selenium framework is mostly used? We have also seen Selenium framework example program with explanation, along with many other FAQs of Selenium beginners.
Next, you can look into other Top Selenium Tutorials from the below links, Or, Check our Free Selenium Framework Mastery Series. If not found, then comment it below, and I’ll try to help you within 24 hours.
Cheers,
Shubham !!
[…] What is Selenium used for? How do I start learning Selenium? [ by LogicalDuniya ] […]