Selenium WebDriver is one of the best automation testing tools in recent years. Therefore, in the IT industry, the demand for Selenium WebDriver based jobs is growing rapidly day by day in the market.
Here, we have listed the best collection of frequently asked Selenium WebDriver Interview Questions with the best possible answers to crack the interviews.
We have also covered the most basic Selenium WebDriver interview questions and answers that will be helpful for freshers.
You can also prepare answers of Java interview questions for Selenium automation testing from basic to advanced.
Frequently Asked Interview Questions in Selenium Basic
1. What is Automation Testing?
Ans: Automation testing is a process of automating manual processes to test applications or systems. It uses separate testing tools in which test script is created and executed repeatedly.
2. What are the benefits of Automation testing?
Ans: There are the following benefits of automation testing. They are as follows:
- Automation testing supports the execution of repeated test cases.
- It supports parallel execution.
- It helps to improve accuracy and reduces human-generated error.
- It saves time and money.
3. What is Selenium? What are the different components of selenium?
Ans: Selenium is a free and open-source browser automation testing tool which is used to test the functionality of web based application. It supports different operating systems and different languages. It is originally developed by Jason Huggins in 2004.
There are four components available in selenium suite to automate the web application.
- Selenium IDE (Integrated Development Environment)
- Selenium Remote Control (RC)
- Selenium Grid
4. Why should Selenium be selected as a testing tool?
Ans: There are the following reasons to select selenium as a testing tool.
- Selenium is free and open-source.
- It supports different operating systems like Windows, Mac OS, and Linux.
- It supports different programming languages such as Java, C#, Python, Perl, Ruby, and PHP. We can code in Java, Python, C#, etc.
- It supports almost all popular browsers like Chrome, Firefox, Opera, IE, etc.
- Selenium supports cross-browser compatibility (Chrome, Firefox, or IE).
5. What is Selenium 1.0?
Ans: Selenium 1.0 or Selenium Remote Control (popularly known as Selenium RC) is a freeware automated testing tool that allows testers to test web-based applications.
It was developed to extend framework in multiple programming languages. It is composed of Selenium IDE, Selenium Core, Selenium RC, and Selenium Server.
6. What is Selenium 2.0?
Ans: Selenium 2.0 (also known as WebDriver) is the latest, free, and open-source library to automate web applications. It is a pure object-oriented tool.
This powerful tool was developed in 2008 when Selenium RC was merged with another testing framework called WebDriver.
7. What are the types of testing supported by selenium?
Ans: Selenium supports different types of testing. They are as follows:
- Functional Testing
- Regression Testing
- Acceptance Testing
- End-to-End Testing
- Smoke Testing
- Sanity Testing
- Responsive Testing
- Cross Browser Testing
- UI Testing
- Integration Testing
8. What are four parameters that have to pass in Selenium?
Ans: Four parameters that have to pass in selenium, are Host, Port Number, Browser, and URL.
9. What are the limitations of Selenium?
Ans: There are the following limitations of Selenium. They are:
- Selenium supports the testing of only web applications.
- Captcha and barcode cannot be tested by using selenium.
- Mobile applications cannot be tested by using Selenium.
- Test reports can only be generated using third-party tools like JUnit or TestNG.
10. What is the difference between Selenium and QTP?
Ans: There are several differences between Selenium and QTP. They are:
a) Open/Licensed: Selenium is free and open-source whereas, QTP is a licensed tool.
b) Operating system: Selenium supports various operating systems like Windows, Mac OS, and Linux whereas, QTP supports only Windows operating systems.
c) Browser: Selenium supports almost all types of browsers like Firefox, Chrome, IE, Opera, Safari, etc whereas, QTP supports only IE.
d) Testing: Selenium supports only testing web-based applications while QTP can be used for testing of both web-based and window-based applications.
e) Programming language: Selenium supports multiple programming languages like Java, C#, Python, Ruby, etc while QTP supports only VB script.
f) Object repository: Object repository needs to be created in selenium whereas QTP automatically creates and maintains object repository.
Interview Questions based on Selenium WebDriver
1. What is Selenium WebDriver?
Ans: Selenium WebDriver is a web automation framework that executes tests against different browsers like Firefox, Chrome, IE, etc.
It allows the users to create test scripts in different programming languages. It was designed by Simon Stewart while he was working at ThoughtWorks.
2. Is WebDriver interface or class?
Ans: WebDriver is a public interface, not a class. We just define a reference variable (driver) of type WebDriver interface. Now, we can assign an instance of a class (such as FirefoxDriver class) that implements WebDriver interface to use methods provided by WebDriver.
WebDriver driver = new FirefoxDriver();
3. How WebDriver is an interface?
Ans: Creating WebDriver as an interface is the best way to expose a set of APIs that will provide a lot of capabilities to the Selenium tool. Selenium developers knew that logic will not be the same for all browsers.
Interface is a mechanism that has only abstract methods i.e methods that have no body or logic. Therefore, WebDriver interface allows users to write their logic in abstract methods provided by WebDriver.
RemoteWebDriver class implements WebDriver interface which is extended by Browser drivers.
4. How Selenium WebDriver works?
Ans: Selenium WebDriver works in three steps. They are as follows:
a. The first step is to send commands (programming code and selenese commands) to the Selenium WebDriver server via commands line associated with selenium server.
c. In the third step, Selenium Web browser driver elements interact with web application using commands from selenium to perform actions of users like entering text, clicking on button, etc.
5. What is the name of super interface of WebDriver?
Ans: SearchContext is the super interface of Webdriver. It is the top most interface in selenium, which is extended by another interface called WebDriver. It has only two methods named findElement() and findElements().
6. What is RemoteWebDriver?
7. What are Programming Languages supported by Selenium WebDiver?
Ans: Selenium WebDriver supports multiple programming languages like Java, C#, Python, Ruby, Perl, and PHP. We can write code in any of these languages.
8. What are Operating Systems supported by Selenium WebDriver?
Ans: Selenium WebDriver supports multiple operating systems such as Windows, Linux, Mac OS, IOS, and Android.
9. How many types of WebDriver APIs are available in Selenium?
Ans: There are several types of WebDriver APIs available in Selenium WebDriver. They are FirefoxDriver, GeckoDriver, InternetExplorerDriver, ChromeDriver, HTMLUnitDriver, OperaDriver, SafariDriver, AndroidDriver, iPhoneDriver, and EventFiringWebDriver.
10. What are testing frameworks supported by Selenium WebDriver with Java?
Ans: Selenium WebDriver with Java supports two testing frameworks such as JUnit and TestNG.
11. Is FirefoxDriver a class or an interface?
Ans: FirefoxDriver is a Java class that implements a WebDriver interface.
12. How do we launch a web browser by using Selenium WebDriver?
Ans: WebDriver is an Interface. We create an object of a required driver class such as FirefoxDriver, ChromeDriver, InternetExplorerDriver, etc by assigning WebDriver reference. For example:
a. To launch Firefox Driver:
WebDriver driver = new FirefoxDriver()
b. To launch Chrome Driver:
WebDriver driver = new ChromeDriver();
c. To launch Internet Explorer Driver;
WebDriver driver = new InternetExplorerDriver();
13. Why do we assign Firefox instance to WebDriver reference such as WebDriver driver = new FirefoxDriver();?
Ans: We assign the FirefoxDriver object to WebDriver reference because it allows assigning driver object with different browser drivers.
If we want to switch other browsers in the same program for multiple browser testing, we will have to create multiple objects for different browsers that are the worst kind of programming. Therefore, we create a WebDriver reference and assign an object of class.
14. What is difference between WebDriver and FirefoxDriver?
Ans: WebDriver is an interface whereas, FirefoxDriver is a class that implements WebDriver interface.
15. How to write test cases using Selenium WebDriver?
Ans: We can write test cases using element Locators, Selenium WebDriver methods, and Java programming features. Element locators are used to locating WebElements on the web page.
Selenium WebDriver methods are used to perform operations on WebElement. Java is used to enhance programming features.
There are five basic steps to write test cases that can be applied to any test case and any application under test (AUT). They are as follows:
- Create a WebDriver instance.
- Navigate to a Web page.
- Locate an HTML element on the Web page using locators.
- Perform an action on an HTML element.
- Run tests.
16. What is Firebug?
Ans: Firebug is a Firefox addon which is used to inspect HTML web elements on the web page during a test.
17. What are the limitations/drawbacks of WebDriver?
Ans: There are many limitations or drawbacks of WebDriver. They are:
a. Selenium WebDriver can be used only to test web-based applications. We can not test Windows-based applications or desktop applications and any other software.
b. It is not possible to perform the testing on the image.
c. WebDriver does not generate automatically test result files.
d. WebDriver cannot support new browsers.
18. Which WebDriver implementation is the fastest?
Ans: HTMLUnit Driver is the fastest WebDriver implementation.
19. What is HTMLUnitDriver in Selenium?
Ans: HTMLUnitDriver is the fastest and most lightweight web browser for implementation of WebDriver. It has no GUI (Graphical User Interface).
Since, in HTML unit driver, test runs in the background without any visual interruption, we cannot see test execution on the screen. Hence, test execution becomes faster than other drivers.
20. What is the difference between HTMLUnitDriver and FirefoxDriver?
Ans: There are following differences between HTMLUnitDriver and FirefoxDriver.
- HTMLUnitDriver is a lightweight web browser whereas, FirefoxDriver is a heavyweight browser.
- HTMLUnitDriver has no plugin whereas, FirefoxDriver has plugin.
- HTMLUnitDriver does not GUI whereas, FirefoxDriver has.
- In the HTMLUnitDriver, test execution is fast whereas, slow execution happens in the FirefoxDriver.