In this tutorial, we have listed all the most important frequently asked interview questions based on Selenium WebDriver framework with the best possible answers. 

Here, we have covered topic-wise questions of Selenium framework, data-driven, keyword-driven, hybrid driven framework, and object repository.


Frequently Asked Questions on Selenium Framework

Selenium framework interview questions
1. What is Selenium Framework?
🅰 Selenium framework is a code structure that is used to make code maintenance simpler and readability better. It helps in dividing the entire code into smaller parts of the code in a systematic way.

2. Why do we need/use of Selenium Framework?
🅰 There are the following reasons to use Selenium Framework in the project. They are as follows:
a. Selenium framework structure breaks the entire code into small parts. These smaller parts can be easily readable if we need to modifying and can perform a particular function.

b. Using selenium framework structure, we can easily find and fix bugs or defects in a million lines of code in a short time.

c. In a test automation project, we use a framework to organize and manage all the files and to finish all the tasks in a systematic way.

d. Selenium framework is easy to use and also provides flexibility in our code.
e. It makes our code simple, understandable, and readable.

3. Is Selenium a tool or framework?
🅰 Selenium is an open-source tool, not a framework.

4. What are the different types of Selenium framework?
🅰 There are three types of test frameworks that we can construct using Selenium WebDriver. These are
1. Data-Driven Framework
2. Keyword Driven Framework
3. Hybrid test framework

5. What are the components of Selenium framework?
🅰 Selenium framework has four components. They are:
a. Selenium Integrated Development Environment (IDE)
b. Selenium Remote Control (RC)
c. WebDriver.
d. Selenium Grid.

6. Have you created any Framework in your project?
🅰 If you are a beginner or fresher or having below 2 years of experience, your answer should be No. I didn’t get a chance to create a framework. I have used the framework in the project which is already available in my organization.

If you are an experienced tester and having 2.5 years experienced, your answer should be Yes or No, depending in your knowledge. I have created a framework. If your answer is No, but I have involved in the creation of the framework.

7. What are the advantages of using Selenium Automation Framework?
🅰 There are several advantages to using a selenium automation framework. They are as follows:
1. Increases code reusability. Create one time and execute multiple times with less or no maintenance.
2. Easier to use.
3. Improved code understandability and readability.
4. The automation framework provides flexibility to code.
5. Reduces script maintenance.
6. It generates automatic test reports after test execution.

8. What are disadvantages of Selenium automation framework?
🅰 Using Selenium automation framework can have also several disadvantages. They are as follows:
1. It consumes more time to develop.
2. Slower to execute.
3. More complex to create and debug.

FAQs on Data Driven Framework

9. What is Data-driven framework?
🅰 A Data-Driven Framework in selenium is a technique in which we keep input test data separate from the actual test script (code). This framework is completely dependent on the input test data. There are two components in the data driven framework. First is test script and second test data.

The test data set is created in the external sources such as an excel file, CSV file, XML or any database table and we then connect test script with test data to get multiple sets of data to perform the software under test.

11. Why do we need/use Data-Driven Framework in Selenium?
🅰 We need to implement a Data-Driven Framework when we have to execute the same test script with different sets of test data. For example, we need to test the login/Register to a web page with 100 different data sets of usernames and passwords.

12. How will you design Data-Driven Framework in Selenium using Apache POI?
🅰 Refer to link: https://www.scientecheasy.com/2019/12/selenium-framework.html


13. What are advantages of Data-Driven framework in Selenium? 
🅰 There are several advantages of using data driven framework in Selenium. They are:
1. Data-driven framework helps to reduce the repetition of the same task again and again.
2. It reduces the number of test scripts needed to implement all test cases.
3. It requires less amount of code to generate all test cases.
4. The test data is created before test implementation.
5. It is secure and easy to maintain.

FAQs on Keyword Driven & Hybrid Driven Framework

14. What is Keyword driven framework?
🅰 Keyword-driven automation framework is a technique in which we represent the test scenario in terms of keywords and corresponding parameters.

In keyword driven framework, keywords are used to write test scripts step-wise in the form of table and functions are called based on keywords to complete an end-to-end flow. 

15. What is keyword in keyword driven framework?
🅰 Keyword represents a user action or function that we would like to test in the application.

16. In which kind of application, keyword-driven framework is the best choice? 
🅰 If you want to test multiple functionalities of application under test, you can go for the best option keyword driven framework in Selenium. Therefore, this framework is also called functional automation testing framework.

17. Why keyword driven framework is also known as table-driven framework?
🅰 Keyword driven framework is also known as table-driven testing because a sequence of test steps and their corresponding inputs are implemented by using a set of keywords in tabular format.

18. What are the main components of keyword-driven framework in Selenium? 
🅰 The most common components for keyword driven automation framework are as follows:
     a. Excel Sheet
     b.Object Repository
     c. Function Library
     d. Test Data Sheet
     e. Test Scripts
     f. Driver Script

19. Why do we perform Keyword-driven testing?
🅰 There are the following reasons to perform keyword-driven testing. 
1. Keyword-driven framework helps to separate test scrip and test data individually which minimizes script modification and maintenance efforts.

2. By separating it, a non-technical person or manual tester can also easily understand automation process and write automation script to automate the functionality of the application.

3. Test execution can be performed automatically by non-technical person or manual tester based on the keyword lists.

4. In keyword driven testing approach, the bug report and its graphical representation are generated automatically which reduces the effort and time of testers.

20. How to perform Keyword-driven testing?
🅰 There are following common steps to perform Keyword Driven Framework in Selenium. They are as follows:
1. Identify all the actions that have to be performed for the test automation of an application.
2. Create a Keyword map table in the excel sheet for identified actions in the test.
3. Create a function/method in java for each action keyword identified in the excel sheet.
4. Write code to read data from excel sheet.
5. Pass test data to these functions to perform operations.

21. What are the advantages of using Keyword driven framework?
🅰 The advantages of using keyword driven framework are as follows:
1. We don't need expertise in automation to maintain or create new test scripts.
2. Keywords can be reused across multiple test scripts or even different software.
3. Easy maintenance of test scripts.
4. Keyword-driven framework is not dependent on a specific programming language or tool
5. It is compatible with any automation tools available in the market.

22. What is Hybrid driven framework?
🅰 Hybrid driven framework is a combination of data driven and keyword driven frameworks which is designed for those applications where we want to test multiple functionalities of application with different sets of Test Data.

23. When should to Design Data Driven, Keyword Driven, and Hybrid Frameworks in Selenium?
🅰 a. Data Driven Framework: Data-driven framework is designed to work with those applications where we want to test multiple sets of data than multiple functionalities of the application.
For example, data-driven framework is generally designed to test the login web page by different sets of Test Data.

b. Keyword Driven Framework: Keyword-driven framework is designed to work with those applications where we want to test multiple functionalities of the application than Test Data.

c. Hybrid Framework: Hybrid framework is designed for those applications where we want to test multiple functionalities of application with different sets of Test Data.

Frequently Asked Question on Object Repository

24. What is Object with respect to Selenium?
🅰 An object is a graphics user element in a web application. For example, a button, edit box, image, link, etc. It basically consists of Data and Functions.

25. What is Object Repository?
🅰 An object repository is a common storage location where we store a collection of all required application objects and their properties. It is mainly used to store element locator values in a central location to avoid hard coding within scripts.

26. What are the advantages of using Object Repository in Selenium Automation?
🅰 The main advantage of using object repository in selenium automation is the separation of objects from test cases. If the locator value of one web element changes, only the object repository needs to be changed rather than making changes in all test cases in which the locator has been used. This will increases the modularity of framework implementation.

27. What are the types of Creating Object Repository in Selenium WebDriver? 
🅰 There are two types of object repositories that can be created in Selenium WebDriver.
1. Object Repository using Properties file
2. Object Repository using XML file

28. What is Properties file in Selenium?
🅰 Properties file in Selenium is a text file wherein data is stored in the form of key-value pairs. We will create properties file to store all element locators. This properties file acts as an object repository in Selenium WebDriver.

29. How do we store data into properties file?
🅰 In the properties file, data is stored in the form of Key-Value pairs. The key-value pair is represented by two string values separated by the equal sign. We store element name and locator values of WebElement into the properties file to identify web elements.

30. How to read data from object repository properties file? 
🅰 Data can be read from properties file using the built-in Properties class provided in java.util package in three steps:
1. First, create an object of the File class and pass properties file path to its constructor.
    File file = new File(path of properties file);
2. Second, create an object of FileInputStream class with passing reference variable "file" of File class object as a parameter to its constructor.
    FileInputStream fis = new FileInputStream(file);
3. Create an object of Properties class and pass reference variable "fis" of FileInputStream class object as a parameter to its constructor. Now, call load() method provided by Properties class in java to read data from properties file. The following complete code is as follows:
    Properties obj = new Properties(); obj.load(fis);
31. How will you use Object Repository in Test scripts?
🅰 Object repository can be used in test scripts by reading data from a properties file and passing the data using the getProperty() method of Properties class as a parameter to the findElement method.

32. What is the return type of getProperty() method?
🅰 The getProperty() method returns the value specified with keys to the findElement() method to locate web elements.