An Overview of Selenium
Selenium is an open-source test automation framework that changed the testing landscape. Developed in 2004 by Jason Huggins, Selenium quickly gained popularity as the web UI automation testing interface. The popularity of Selenium can be attributed to its ability to support multiple programming languages to write test scripts such as Python, PHP, Java, Perl, Ruby, and C#. In addition, it supports all major browsers such as Firefox, Chrome, Internet Explorer, and Safari. Platforms like Windows, MAC, Linux, Solaris, and mobile OSes such as Android, iOS, and Windows Mobile are all capable of running Selenium.
Selenium is a testing framework that comprises of multiple tools:
- Selenium Integrated Development Environment (IDE): A Firefox and Chrome add-on that allows you to record and run actions on a browser
- Selenium WebDriver: A suite of language-specific bindings to control browser actions from the OS level
- Selenium Grid: A feature to simultaneously run test scripts on multiple machines running on multiple platforms
The Evolution of Selenium
Considering the complexity in installing and configuring Selenium RC, Simon Stewart developed WebDriver in 2006 that allowed the control of a browser from the OS while supporting cross-platform testing. Consequently, Selenium RC and WebDriver were merged with the introduction of Selenium 2 in 2008.
What is Selenium Grid?
Running test scripts on multiple devices and platforms is time-consuming and cumbersome as well. To minimize test times, Patrick Lightbody created a feature called ‘Hosted QA’, which enabled him to simultaneously run test cases on different devices running on different platforms. It was later renamed Selenium Grid. Using Selenium Grid, QA and developers teams were able to run different test scripts on different browsers running on different platforms, saving significant test times.
The Selenium Grid Architecture
The Selenium Grid architecture consists of two core components
- Selenium Grid Hub: It acts as a central system that receives test case requests from clients and distributes them to different nodes based on desired capabilities. You can use only one node in a grid.
- Selenium Grid Node: A node machine is connected to the hub which will receive test scripts from the hub and executes them. You can launch several nodes on different devices running different environments.
Guide to install and setup a Grid
Here are the steps to install and set up a Selenium Grid
Step 1: Install Java and Configure Environmental Variables
To use Selenium Grid, you need to install a Selenium server which comes in the form of Jar files. To use the jar files, you need to install Java on your machine and configure environmental variables. If you already have Java installed, you can skip this step.
a) Visit this link to download and install Java:
b) To set the Java installation path:
- Right-click on the Start button and go to settings
- Choose ‘Advanced Settings’ and Go to ‘Environmental Variables’
- Click New and enter the variable name as JAVA_HOME
- Enter the Java JDK path as the Variable value and click ok.
Step 2: Download and Install Selenium Server
Visit this link to download the Selenium server.
The latest stable version is 3.141.59. You can store the jar files in any location on your machine. For consistency across the hub and node machines, save them in the C drive. So, now you have the Selenium server jar files on the hub and the node machine.
Step 3: Configure the Hub Machine
- Click Start and open the Command Prompt
- Navigate to the location where the selenium server jar files are stored (eg: C:)
- Type the following command:
java -jar selenium-server-standalone-3.141.59.jar -role hub
Here 3.141.59 is the server version. If you are using a different version, change the version number accordingly.
This command will launch the machine as a Selenium Grid hub on the default port 4444. You can change the default by specifying the IP address using the parameter ‘-host’
To check if the hub is running, open a browser window and type the following URL:
When you click on ‘View Config’ option, it will display the details:
Step 4: Configure Selenium Grid Node
- Open the command prompt on the node machine and navigate to the location where selenium server jar files are stored.
- Type the following command:
java -jar selenium-server-standalone-3.141.59.jar -role node -hub http://192.168.0.4:4444/grid/register -port 5555
The IP address is the IP address of the machine wherein you have installed the hub and port is the hub port (4444 here). To know the IP address of the hub machine, simply type: ipconfig in the command prompt of the hub machine.
When you use multiple nodes, you can use the same command to register each node with the hub.
By default, the grid allows 5 chrome browsers, 5 firefox browsers, and 1 IE browser.
To change these settings, type the following command:
Now the grid hub and the node machines are configured and ready to use. You can use an IDE such as Eclipse and write WebDriver code to execute test scripts on node machines.
Challenges around maintaining a Grid
While Selenium Grid is a powerful tool to perform test automation, cross-platform testing, and mobile testing, in particular, is only possible when you integrate mobile test automation frameworks such as Appium or Selendroid. While Selendroid offers limited options, Appium is a robust framework but comes with a huge learning curve. The test environment setup requires a lot of time and effort. You should develop reusable libraries. When testing hybrid apps with Appium, switching between the web and native views is repeatedly done. Web element identification is not easy too and doesn’t work sometimes. Test object identification is not available too.
When it comes to performance, the selenium grid slows down with the increase in the number of nodes. At the same time, the test that executes on the local machine makes it hard to download or install additional software. Setting up the parallel testing environment is cumbersome too. Reporting and analytics is another key challenge. Selenium doesn’t offer any reporting tool which means you can’t generate comprehensive test reports for a holistic view of the test across the teams. The only option is to integrate and configure a reporting and analytic tool that adds up to the burden of testers. When CI/CD is involved, reporting becomes even more critical as the test suites are broken into smaller segments. Without a comprehensive reporting system, tracking and resolving issues becomes difficult. Adding and removing devices on the go adds up to this challenge.
SeeTest takes Selenium Grid to a new level
SeeTest, a proprietary mobile test automation framework from Experitest, enables developers and QA teams to fully leverage Selenium Grid capabilities while overcoming its limitations. Here are the key advantages of using SeeTest:
Highly Scalable Solution
SeeTest is a highly scalable test automation solution. You can easily scale with hundreds of sessions and the tool delivers 100% performance every time. Unlike other tools, SeeTest performance doesn’t deteriorate even when you add hundreds of node servers. You can add a device on the go or remove a device without any downtime or need to make configurational changes.
Cross-Platform Testing Made Easy
Working with SeeTest and Selenium is simple and easy. You can easily connect to the centralized SeeTest hub that offers a range of Android, iOS and other browser combinations when you integrate your Selenium test environment with the SeeTest Mobile and Browser Lab. Run parallel testing on hundreds of browsers running on different platforms once setup is complete.
Continuous Testing Made Easy
In today’s DevOps era, CI/CD is more of a necessity than an option. SeeTest enables you to easily integrate your CI/CD environment such as Bamboo or Jenkins and continuously run tests anytime. It means you don’t have to worry about the programming language, test framework, or the IDE but simply focus on creating the best product.
Dedicated Support Team
Cross-platform test automation tools such as Appium comes with a significant learning curve with regard to installation, configuration, and operations. Moreover, being open-source, Appium is constantly undergoing changes and upgrades. So, you’ll always have to rely on online communities to identify and solve issues with the tool. However, SeeTest comes with a dedicated support team that helps you with every issue anytime 24/7. It means your time is highly productive.
Realtime testing across the globe
The striking feature of SeeTest Mobile and Browser Lab is that the data centers are located in 8 different regions. It means you not only access a wide range of browsers running on different platforms and located across the globe but you can also check latency issues in real-time.
Reporting and Analytics
Reporting and Analytics is a big advantage of SeeTest. It offers text, video recordings, screenshots, browser console, and network logs, etc. covering every step of the test. SeeTest Dashboard is a centralized analytics dashboard that enables you to get clear insights into key metrics. Furthermore, the automatic root cause analysis feature of this dashboard helps you to easily identify the root cause and quickly take corrective actions.
Simply put, SeeTest does all the mobile test automation tasks while you can focus more on your product.