Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Topic-wise Selenium Interview Questions and Answers

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 and the best possible answers to crack the interview.

Top Selenium WebDriver Interview Questions and Answers


Frequently Asked Interview Questions in Selenium Basic

1. What is Automation Testing?
 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 benefits of Automation testing?
 There are the following benefits of automation testing. They are as follows:
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.
1. Selenium IDE (Integrated Development Environment)
2. Selenium Remote Control (RC)
3. WebDriver
4. Selenium Grid
 
4. Why should Selenium be selected as a testing tool?
 There are the following reasons to select selenium as a testing tool.
1. Selenium is free and open-source.
2. It supports different operating systems like Windows, Mac OS, and Linux.
3. It supports different programming languages such as Java, C#, Python, Perl, Ruby, and PHP. We can code in Java, Python, C#, etc.
4. It supports almost all popular browsers like Chrome, Firefox, Opera, IE, etc.
5. Selenium supports cross-browser compatibility (Chrome, Firefox, or IE).

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.

 
6. What is Selenium 2.0?
 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?
 Selenium supports different types of testing. They are as follows:
a. Functional Testing
b. Regression Testing
c. Retesting
d. Acceptance Testing
e. End-to-End Testing
f. Smoke Testing
g. Sanity Testing
h. Responsive Testing
i. Cross Browser Testing
k. UI Testing
l. Integration Testing
 
8. What are four parameters that have to pass in Selenium?
 Four parameters that have to pass in selenium, are Host, Port Number, Browser, and URL.
 
9. What are the limitations of Selenium?
 There are the following limitations of Selenium. They are:
1. Selenium supports the testing of only web applications.
2. Captcha and barcode cannot be tested by using selenium.
3. Mobile applications cannot be tested by using Selenium.
4. Test reports can only be generated using third-party tools like JUnit or TestNG.
 
10. What is the difference between Selenium and QTP?
 There are many differences between Selenium and QTP.
1. Open/Licensed: Selenium is a free and open-source whereas, QTP is a licensed tool.
2. Operating system: Selenium supports various operating systems like Windows, Mac OS, and Linux whereas, QTP supports only Windows operating system.

3. Browser: Selenium supports almost all types of browsers like Firefox, Chrome, IE, Opera, Safari, etc whereas, QTP supports only IE.

4. Testing: Selenium supports only testing web based applications while QTP can be used for testing of both web based and window based applications.

5. Programming language: Selenium supports multiple programming languages like Java, C#, Python, Ruby, etc while QTP supports only VB script.

6. Object repository: Object repository needs to be created in selenium whereas QTP automatically creates and maintains object repository.

FAQs on Selenium WebDriver

1. What is Selenium WebDriver?
 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 script in different programming languages. It was designed by Simon Stewart while he was working at ThoughtWorks.

2. Is WebDriver interface or class?
 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.
For example:
        WebDriver driver = new FirefoxDriver();

3. How WebDriver is an interface?
 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 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?
 Selenium WebDriver works in three steps. They are as follows:
1. The first step is to send commands (programming code and selenese commands) to the Selenium WebDriver server via commands line associated with selenium server.

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?
 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?
 RemoteWebDriver is a class which extends object class and implements WebDriver, and JavascriptExecutor interfaces. 

7. What are Programming Languages supported by Selenium WebDiver?
 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?
 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?
 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?
 Selenium WebDriver with Java supports two testing frameworks such as JUnit and TestNG.

11. Is FirefoxDriver a class or an interface? 
 FirefoxDriver is a Java class that implements a WebDriver interface.

12. How do we launch a web browser by using Selenium WebDriver?
 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();?

 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?

 WebDriver is an interface whereas, FirefoxDriver is a class which implements WebDriver interface.

15. How to write test cases using Selenium WebDriver?
 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:
1. Create a WebDriver instance.
2. Navigate to a Web page.
3. Locate an HTML element on the Web page using locators.
4. Perform an action on an HTML element.
5. Run tests.

16. What is Firebug?
 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?
 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:
1. Selenium RC supports various types of browsers like Mozilla Firefox, Google Chrome, Internet Explorer and Opera.
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:
1. WebDriver supports almost all popular browsers like Mozilla Firefox, Google Chrome, Internet Explorer, Opera, etc.
2. It is a pure object-oriented tool.
3. It does not support record and playback features.
4. It does not need any server to be started before execution of test scripts.
5. WebDriver supports dynamic finders and the implementation of listeners.
6. WebDriver is faster than Selenium RC.
7. WebDriver supports testing of iPhone/Android applications by the available tool.

FAQs on Selenium WebDriver Commands 

1. How to open a Website using Selenium WebDriver?
 The get() method is used to open the specified URL in the current browser window. The URL must be in the form of http://www.xyz.com. If the http is not included then it will throw a message “Cannot navigate to invalid URL”.
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();

 
3. How to get Page Title of web page using Selenium WebDriver?
 getTitle() method of WebDriver is used to get page title of any web page. The syntax is as follows:
      String pageTitle = driver.getTitle();
         System.our.println(pageTitle);

4. How to get a text from a specified element or object on web page?
 The getText() method is used to retrieve inner text of specified element on web page. The syntax is given below:
Syntax:
        driver.findElement(By.locatorName(“Specified Element”)).getText();
 
5. How to compare page title on web page with expected title in Selenium WebDriver using Java?
 We will verify or compare the title of the web page in Selenium WebDriver using the String concept of Java. Let’s see the main source code.

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?

 The close() method is used to close only the browser window that WebDriver is currently controlling whereas, the quit() method is used to close all windows opened by WebDriver.

8. What are Navigation commands in Selenium WebDriver?
 Navigation commands are those commands in Selenium that are used to perform different operations such as backward, forward, refresh, wait, etc in the browser’s history. The navigation commands available in Selenium WebDriver are back, forward, refresh, navigate and to.

9. How to move forward and backward on the web page?
 forward() method is used to move forward by one page on the browser’s history.
back() method is used to move back by one page on the browser’s history.

10. What is WebElement? Is WebElement class or interface?
 The elements that are present on a web page are called WebElement. It represents an HTML element. Text boxes, links, buttons, dropdown buttons, radio buttons, labels, and forms are called WebElement. It is an interface.

11. How many methods have been provided by Selenium WebDriver to find WebElement?
 There are two methods available in Selenium WebDriver to find WebElement.
1. findElement(): This method is used to locate one web element in the current web page using the locator provided in the parameter list. 

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?
 The return type of findElement() method is a WebElement object whereas, findElements() method returns a list of WebElements.
 
13. Which input parameter does findElement() method take?
 The findElement() method takes an input parameter of type By. By is an instance of By class.
 
14. Which exception is thrown by WebDriver when it is unable to find an element on web page?
 Runtime exception named NoSuchElementException.
 
15. What is the difference between findElement and findElements?
 Refer to answer 11 and 12.
 
16. How will you find more than one WebElement on the list?
 findElements() method of WebDriver can be used to find more than one web elements and save them into a list.
 
17. How to clear text in the text box using Selenium WebDriver?
 The clear( ) method provided by Selenium WebDriver is used to clear the text entered or displayed in the text box.
 
18. How to submit a form using Selenium WebDriver?
 The submit() method is used to submit a form with
tag. It accepts nothing as a parameter and returns nothing. It will throw NoSuchElementException if the current element is not present within a form.
 
19. How to send user input in the text box using Selenium WebDriver?


This post first appeared on Scientech Easy, please read the originial post: here

Share the post

Topic-wise Selenium Interview Questions and Answers

×

Subscribe to Scientech Easy

Get updates delivered right to your inbox!

Thank you for your subscription

×