Interested In Browser Automation? Let’s Learn That With Selenium Web Driver
Selenium is a very prominent tool to launch & control a browser instance using many popular programming languages. It’s commonly used for testing web applications, automation, as well as web scraping (which can be illegal).
In this series, we will take a look at Selenium Web Driver, and learn how to use it to control a web browser in various ways. From launching the browser, filling forms and clicking on elements, to closing the browser instance after we are done. We will also cover some of the less common cases you may encounter as well. While most of this series is hand-on, there will be a good amount of theoretical info about selenium. Even though I will focus on Java in the practical lessons, I made this series so that all the non-Java posts are in separate posts. That means I can fork the series to include other popular languages like Python or C# in the future.
You can find links to each post in the series down here:-
☇
Quickly go to:-
Requirements For This Series
To fully understand & benefit from this series, you need to know some Java, and to be able to at least do some basic coding with it. I also assume you know how to use Eclipse or another IDE of your choice. If you don’t have an IDE, I will explain how to download Eclipse when we get to use Selenium with it.
What Is Selenium Web Driver
Selenium is an open-source tool (or tools, since there are quite a few) that allows you to launch & control a web browser. That’s done using native operating system calls & JavaScript. It is commonly used for testing web-applications, but it can also be used for other purposes, like automation or web-scraping. It supports all the main browsers we know of, making it suitable to test websites & applications on each browser. It also can be used with many programming languages, from Java to JavaScript. We will get to the supported browsers & programming languages later in this article.
Different Flavors Of Selenium
Selenium Remote Web Driver
Selenium remote Web Driver is a server that receives & executes commands from the client driver, which is available for PHP, Python, Ruby, .NET, Perl & Java. The server can be either on same machine as the client, or in a separate machine. It makes it easy to do testing on browsers on a different operating system (the server can be on a Mac OS or Linux machine, and the client is on a Windows one). It is also called Selenium Remote Control or Selenium RC. It’s how Selenium used to be before Selenium 2.0 was released & Web Driver became its main component (and was deprecated in favor of it). Despite tha t, you may still hear it in some websites. Since it’s deprecated, I don’t advise you to use it to run Selenium instances on another server. You better use Selenium Grid for that, which we will talk about shortly.
Selenium Web Driver.
Selenium Web driver does everything Remote Web Driver does, but using one component, which is the Web Driver. It uses operating system calls whenever possible to interact with the browser rather than JavaScript. This solves the subtle problems resulted from the difference between native operating system and JavaScript commands, including security restrictions
In additional to supporting all the main browsers. Web Driver also supports HTMLUnit browser, which is a headless browser without a user interface.
Selenium Web Driver will the one the focus of this series.
Selenium IDE
Selenium IDE is an Add-On that makes it easy & fast to record tests on the Firefox & Chrome. Specially for those who don’t know coding. It used to be called Selenium Recorder. After the test is recorded, the user can edit the recorded commands and add new ones on the user interface, as well as run the updated test.
A similar unofficial Firefox add-on to Selenium IDE called is Kantu is also available.
Selenium Grid
While the Selenium Web Driver can be used to do a good amount of tests manually. Testing an application on each browser & operating system can be a bit time-consuming. The larger the application, the more test cases the testing requires, and the more time it takes to finish the test.
Selenium Grid solves this problem by making it possible to launch multiple test instances on multiple machines, thus reducing the time it takes to do the testing.
There are two components of Selenium Grid:-
- Central Hub:- Takes requests from the Web Driver & executes them in the corresponding node. There can only be one hub in Selenium Grid, and it’s responsible for managing the nodes.
- Nodes:- This is where the testing actually happens. Each node can have multiple browser instances. Unlike the hub, there can be multiple nodes, and each node needs to be registered with the hub.
What Programming Languages Selenium Web Driver Supports
Selenium Web Driver supports many popular programming languages. Including the ones mentioned in Selenium’s website:-
-
- Ruby
- Java
- Python
- C#
- JavaScript
Besides these languages, there are other programming languages with a Web Driver client:-
-
- PHP
- Perl
- Haskell
- Rust
- Kotlin
Even if your programming language of your choice isn’t listed up there. Someone probably created a Web Driver client for it.
Supported Browsers
Selenium supports all the main browsers in the market. Which makes it very powerful for testing web application no matter what browser the application user uses.
Here’s a list of the browsers you could use with the Web Driver:-
-
- Mozilla Firefox
- Microsoft Internet Explorer
- Safari
- Opera
- Google Chrome
- Microsoft Edge
- HTMLUnit
Selenium also supports testing using mobile browsers, like mobile Safari & mobile Chrome
And Finally
We took a quick tour around Selenium & its components, and got to know all the variations of it, including the supported programming languages & browsers. In the next lesson, we will get to download Eclipse & write our first automated test.
☇
Sources & Useful Links
See Also:-
-
- What are 60% Keyboards (65%)? And what are their advantages & disadvantages – Tech Fairy
- 40% Keyboards Form Factor, What are they? And why would you use one? – Tech Fairy
- Why ThinkPad laptops are popular, and what are their advantages?
- What are business-grade laptops? What are their advantages? And which one to buy?
- Java VS Python VS C# detailed comparison, which language to learn first?
- Do you need an Expensive motherboard for gaming?
- What is the meaning of the different USB port colors? (blue, teal blue, yellow, red, black)
- Why motherboards & laptops still come with USB 2.0 ports When USB 3.0 Is Backward Compatible?
- USB 2.0 VS USB 3.0 Comparison: What are the differences between the two ports?
- History Of Graphics card motherboard slots: PCI VS AGP VS PCI-Express VS Integrated graphics.
- What are the advantages & disadvantages of using a Trackball? And why you should use one
- What’s the difference between remake & remaster? (With multiple examples).