Introduction to Selenium
The following article provides an outline for Selenium Software. Selenium is a test automation framework that can be used for web applications. It is an open-source software, and so it can be used at zero cost. This is one of the very few automation testing tools that work on multiple operating systems, including Mac, Linux, and Windows operating systems. It is supported by an assortment of programming languages and programming scripts, such as PHP, Perl, Java, Python, JavaScript, etc.
Why Selenium?
First, say no to manual testing. Why? Ah! Well, in my opinion, we do not like to do the same task again and again. It is boring, time-consuming, and mistakes? No No No No. We are smart and we know our way around. Why not have a program to do it? Here comes the answer Selenium. Execution through scripts, generation of reports, and life is set. There are obviously other tools in the market to choose from like HP’s QTP (Quick Test Professional), IBM’s RFT (Rational Function Tester) but both are proprietary.
Features | Selenium | HP’s QTP | IBM’s RFT |
Open Source | Yes | No | No |
Customer Support | Open source community | HP support | IBM support |
OS Support | Windows, Linux, and Mac | Windows | Windows |
Programming Experience | Ample experience needed | Not needed | Required |
CPU Constipation during Execution | Low | High | High |
Programming Language Support | Java, Ruby, Perl, Python, C#, PHP and JavaScript | VB script | Java and C# |
4 Components of Selenium in Software
Selenium suite has 4 components and each of them has their significance:
1. Selenium IDE (Integrated Development Environment)
A browser extension that has recording and playback features to increase the speed in creating test cases.
A sample recording could be:
The above screenshot is taken from my Google Chrome Selenium extension. To download your go to the extension page of your browser and try installing Selenium IDE. Give a try on recording and running the script. As you can see it captures the execution time for each step which is very helpful in performance testing.
2. Selenium RC (Remote Control) or Selenium 1
It had 2 components Selenium RC Server and Selenium RC Client to overcome the problem of the same-origin policy. It tricked the browser into believing that the request is coming from the same domain. It is now deprecated and merged with WebDriver due to the slow performance.
4.5 (9,614 ratings)
View Course
3. WebDriver
It is a cross-platform testing framework that could control the browser from the OS level. It provides the programming interface to create and execute test cases. It is much faster than Selenium RC.
There are different WebDrivers available based on your choice to perform the testing:
- Chrome Driver
- Firefox Driver (Geko Driver)
- Internet Explorer Driver
- Opera Driver
- HTML Unit Driver safari Driver
You can consider the sample code below for testing a link of eduCBA. The code is written in Java and uses Chrome WebDriver. We have added a selenium jar into my classpath and also I have downloaded chromedriver.exe and placed it into my D: drive. If your project is Maven-based or Gradle go ahead and add the dependency.
Code:
public class ChromeTest {
public static void main(String[] args) throws IOException {
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("disable-gpu");
chromeOptions.addArguments("window-size=1200,1100");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://www.educba.com/");
By link = By.xpath("//a[text()='Certification Courses']");
WebElement element = driver.findElement(link);
System.out.println(element.getText());
driver.quit();
}
}
This will try and capture the <a> tag with text “Certification Courses” and after that print the text on the console. As you can see to capture an element we are using XPath. But there are other methods too to capture the element like id(), name(), link text(), etc on the webpage. Selenium has a rich set of features that covers a variety of solutions. You can also run your tests in headless mode by setting the ChromeOptions property. When you have a requirement of a test case running continuously and you also want to reduce the consumption of your system resources headless mode would be a good option to opt for.
4. Selenium Grid
Selenium Grid is used with RC to run the test on a remote machine. We can run multiple scripts with Grid. It is capable of capturing screenshots during execution and also sends out the selenium commands to the machines in parallel. It utilizes the hub and node concept. Hub as a central source and nodes connected to it.
Now you can spend your money if you want to. We saw different flavors of Selenium. You can easily identify what to choose amongst them. Companies have a special profile for this kind of role and if you want to go in this field, learning Selenium could be a good start, but hey know your career path before you choose anything.
Advantages and Disadvantages of Selenium Software
Given below are the advantages and disadvantages mentioned:
Advantages
As selenium is open source there is no licensing cost involved and to talk about other advantages:
- The test scripts can be written in any of these programming languages: Java, C#, .Net, Ruby, PHP, Python, and Perl.
- One can carry out the test on any of these web browsers: Google Chrome, Mozilla Firefox, Internet Explorer, Safari or Opera
- One can carry out the testing on any of these operating systems: Linux, Windows or Mac.
- Selenium can also be integrated with Maven (Build Automation Tool), Jenkins and Docker for continuous testing.
Disadvantages
Let us know that selenium can only be used for testing web applications.
Also, there are few limitations listed below, which one should know before proceeding further:
- Selenium does not have any customer support system, but one can surely utilize the available customer communities.
- Selenium does not support testing on images. But Selenium can be integrated with Sikuli (GUI Automation Tool) for image-based testing.
Recommended Articles
This is a guide to Selenium Software. Here we discuss the top 4 components of selenium in software, along with the advantages and disadvantages of Selenium. You can also go through our other suggested articles to learn more–