Here, we have listed the best collection of frequently asked Selenium Webdriver Interview Questions and the best possible answers to crack the interview.
Top Selenium WebDriver Interview Questions and Answers
Frequently Asked Interview Questions in Selenium Basic
1. Automation testing supports the execution of repeated test cases.
2. It supports parallel execution.
3. It helps to improve accuracy and reduces human generated error.
4. It saves time and money.
3. What is Selenium? What are the different components of selenium?
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.
5. What is Selenium 1.0?
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.
4. Test reports can only be generated using third-party tools like JUnit or TestNG.
FAQs on Selenium WebDriver
2. Is WebDriver interface or class?
3. How WebDriver is an interface?
Interface is a mechanism that has only abstract method 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?
2. In the second step, Selenium WebDriver Server sends Javascripts commands to Web Browser Driver. The interaction from Selenium WebDriver server to driver elements of web browser is done with the help of Javascript Libraries.
3. In 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?
7. What are Programming Languages supported by Selenium WebDiver?
8. What are Operating Systems supported by Selenium WebDriver?
9. How many types of WebDriver APIs are available in Selenium?
10. What are testing frameworks supported by Selenium WebDriver with Java?
11. Is FirefoxDriver a class or an interface?
12. How do we launch a web browser by using Selenium WebDriver?
13. Why do we assign Firefox instance to WebDriver reference such as WebDriver driver = new FirefoxDriver();?
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?
15. How to write test cases using Selenium WebDriver?
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:
16. What is Firebug?
17. What are the limitations/drawbacks of WebDriver?
There are many limitations or drawbacks of WebDriver. They are:
1. 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.
2. It is not possible to perform the testing on the image.
3. WebDriver does not generate automatically test result file.
4. WebDriver cannot support new browsers.
18. Which WebDriver implementation is the fastest?
HTMLUnit Driver is the fastest WebDriver implementation.
19. What is HTMLUnitDriver in Selenium?
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 run 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?
There are following differences between HTMLUnitDriver and FirefoxDriver.
1. HTMLUnitDriver is a lightweight web browser whereas, FirefoxDriver is a heavyweight browser.
2. HTMLUnitDriver has no plugin whereas, FirefoxDriver has plugin.
3. HTMLUnitDriver does not GUI whereas, FirefoxDriver has.
4. In the HTMLUnitDriver, test execution is fast whereas, slow execution happens in the FirefoxDriver.
21. What are the differences between Selenium IDE, Selenium RC, and WebDriver?
Selenium IDE:
1. Selenium IDE is a Firefox plugin that supports only Firefox.
2. It is a Javascript based framework.
3. It is not object-oriented tool.
4. Selenium IDE supports record and playback features.
5. Selenium IDE does not need any server to be started before executing the test script.
6. It does not support dynamic finders and listeners.
7. Selenium IDE does not support the testing of Andriod/iPhone applications.
Selenium RC:
2. It is a Javascript-based framework.
3. Selenium RC is a semi object-oriented tool.
4. It does not support record and playback feature.
5. Selenium RC requires server to be started before executing the test scripts.
6. Selenium RC also not support dynamic finder and listener.
7. Selenium RC does not support the testing of iPhone/Android applications.
WebDriver:
FAQs on Selenium WebDriver Commands
The syntax is as follows:
WebDriver driver = new FirefoxDriver();
driver.get(“https://www.xyz.com“);
2. How to click on a button of web page?
click() method is used to click on a button of web page. The syntax is given below:
driver.findElement(By.id(“submit”)).click();
4. How to get a text from a specified element or object on web page?
String actualTitle = driver.getTitle(); String expectedTitle=”Facebook – log in or sign up”; // Use equalsIgnoreCase() method of String class to verify actual title with expected title. if(actualTitle.equalsIgnoreCase(expectedTitle)) { System.out.println(“Verification is success” ); System.out.println(“Home page title is:” + actualTitle ); } else { System.out.println(“Verification is failed, Matched not found”); }6. What is difference between driver.get() and driver.navigate() method?
The difference between get() and navigate() methods of Selenium WebDriver are as follows:
1. The driver.get() method is used to open a specified URL of web application and wait until the whole page gets loaded whereas, driver.navigate().to() method is used to navigate a specified URL of web application and it does not wait till the whole page gets loaded.
2. driver.get() method does not maintain the browser history and cookies whereas, driver.navigate() method maintains the browser history and cookies.
3. We can not go forward or backward between the pages using the driver.get() whereas, we can easily navigate between the pages forward, back, and refresh using driver.navigate().
7. What is the difference between close and quit methods of Selenium WebDriver?
8. What are Navigation commands in Selenium WebDriver?
9. How to move forward and backward on the web page?
10. What is WebElement? Is WebElement class or interface?
11. How many methods have been provided by Selenium WebDriver to find WebElement?
2. findElements(): This method is used to find a list of web elements (i.e. multiple elements) on the current web page using the locator provided in the parameter list.
12. What is the return type of findElement and findElements?