In this tutorial, we have listed all the most important frequently asked Selenium framework interview questions based on the best possible answers.
Here, we have covered topic-wise questions of Selenium framework, data-driven, keyword-driven, hybrid driven framework, and object repository.
1. What is Selenium Framework?
Ans: 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?
Ans: 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?
Ans: Selenium is an open-source tool, not a framework.
4. What are the different types of Selenium framework?
Ans: There are three types of test frameworks that we can construct using Selenium WebDriver. These are
- Data-Driven Framework
- Keyword Driven Framework
- Hybrid test framework
5. What are the components of Selenium framework?
Ans: Selenium framework has four components. They are:
a. Selenium Integrated Development Environment (IDE)
b. Selenium Remote Control (RC)
d. Selenium Grid.
6. Have you created any Framework in your project?
Ans: 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 of experience, 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?
Ans: There are several advantages to using a selenium automation framework. They are as follows:
- Increases code reusability. Create one time and execute multiple times with less or no maintenance.
- Easier to use.
- Improved code understandability and readability.
- The automation framework provides flexibility to code.
- Reduces script maintenance.
- It generates automatic test reports after test execution.
8. What are the disadvantages of Selenium automation framework?
Ans: Using Selenium automation framework can have also several disadvantages. They are as follows:
- It consumes more time to develop.
- Slower to execute.
- More complex to create and debug.
FAQs on Data Driven Framework
9. What is Data-driven framework?
Ans: 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?
Ans: 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?
Ans: Refer to link: https://www.scientecheasy.com/2019/12/selenium-framework.html
13. What are the advantages of Data-Driven framework in Selenium?
Ans: There are several advantages of using data driven framework in Selenium. They are:
- Data-driven framework helps to reduce the repetition of the same task again and again.
- It reduces the number of test scripts needed to implement all test cases.
- It requires less amount of code to generate all test cases.
- The test data is created before test implementation.
- It is secure and easy to maintain.
FAQs on Keyword Driven & Hybrid Driven Framework
14. What is Keyword driven framework?
Ans: Keyword-driven automation framework is a technique in which we represent the test scenario in terms of keywords and corresponding parameters.
In the 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: The most common components for keyword driven automation framework are as follows:
a. Excel Sheet
c. Function Library
d. Test Data Sheet
e. Test Scripts
f. Driver Script
19. Why do we perform Keyword-driven testing?
Ans: There are the following reasons to perform keyword-driven testing.
a. Keyword-driven framework helps to separate test scrip and test data individually which minimizes script modification and maintenance efforts.
b. 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.
c. Test execution can be performed automatically by non-technical person or manual tester based on the keyword lists.
d. 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?
Ans: There are following common steps to perform Keyword Driven Framework in Selenium. They are as follows:
- Identify all the actions that have to be performed for the test automation of an application.
- Create a Keyword map table in the excel sheet for identified actions in the test.
- Create a function/method in java for each action keyword identified in the excel sheet.
- Write code to read data from excel sheet.
- Pass test data to these functions to perform operations.
21. What are the advantages of using Keyword driven framework?
Ans: The advantages of using keyword driven framework are as follows:
- We don’t need expertise in automation to maintain or create new test scripts.
- Keywords can be reused across multiple test scripts or even different software.
- Easy maintenance of test scripts.
- Keyword-driven framework is not dependent on a specific programming language or tool
- It is compatible with any automation tools available in the market.
22. What is Hybrid driven framework?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: 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?
Ans: The getProperty() method returns the value specified with keys to the findElement() method to locate web elements.
Recommended Post for Interview
1. TestNG Interview Questions
2. Topicwise Selenium Interview Questions and Answers
3. Selenium Interview Questions asked in Companies
4. Wipro Selenium Interview Questions
5. Java Interview Questions for Selenium Automation Testing
Hope that this tutorial has covered almost all important Selenium Framework interview questions with the best possible answers. I hope that you will have understood answers to all questions.
Please, share it with your friends on social networking sites
Thanks for reading!!!