Selenium Questions Part11: Selenium Framework Questions

1. What is a Framework?

Answer:  A set of guidelines like coding standards, test-data handling, object repository treatment etc. Which when followed during automation scripting produce beneficial outcomes like increase code re-usage, higher portability, reduced script maintenance cost etc. Mind you these are just guidelines and not rules; they are not mandatory and you can still script without following the guidelines. But you will miss out on the advantages of having a Framework.

2. What are the different types of Frameworks?

Answer:  Types of Automated Testing Frameworks

  • Linear Automation Framework - It's sometimes known as a linear scripting framework or a record and play back framework. It works like this: testers create and write test scripts sequentially, performing it individually for each individual test case, hence the record and play back.
  • Modular Based Testing Framework - Modular framework is like creation of small, independent scripts that represents modules, sections and functions of the application under test. Testers use Modular testing framework to divide an application into multiple modules and create test scripts individually.
  • Library Architecture Testing Framework - It divides the application-under-test into procedures and functions in its place of scripts. This framework requires the creation of library files that represent modules, sections, and functions of the application-under-test.
  • Data-Driven Framework - Data-driven is a test automation framework which stores test data in a table or spread spreadsheet format.
  • Keyword-Driven Framework - A keyword-driven framework is a table-driven testing or action word based testing. This is used to speed up automated testing by utilizing the keywords for a common set of actions.
  • Hybrid Testing Framework - Hybrid Driven Framework is a combination of both the Data-Driven and Keyword-Driven framework. ... Keywords are maintained in a separate Java class file and test data can be maintained either in a properties file/excel file

3. What is the principle difference between a Data-driven framework and a Keyword Driven Framework?

Answer: In data driven testing, we can run our tests on multiple data in multiple combinations with the help of parameterization. Here the data is treated as an input to the test script logic. Each data set can be treated as a separate test case.

In keyword driven testing, the keywords that are developed represent an action. A list of keywords maintained in sequence form a test case. Thus a keyword once developed can be used in multiple test scripts.

4. What are the advantages of Automation Framework?

Answer: Utilizing a framework for automated testing will increase a team’s test speed and efficiency, improve test accuracy, and will reduce test maintenance costs as well as lower risks. They are essential to an efficient automated testing process for a few key reasons: 

  • Improved test efficiency
  • Lower maintenance costs
  • Minimal manual intervention
  • Maximum test coverage
  • Re usability of code

5. What are the different components of your framework and explain each?

Answer: Please refer below article to understand about different component in a framework

https://www.automationtestinginsider.com/2020/02/selenium-data-driven-framework-with-pom.html

6. While explaining the framework, what are points which should be covered?

Answer: This question answered in detail on question#8

7. How do you decide a particular framework for a project?

Answer: To help determine which framework is right for your organization, ask yourself the following helpful questions:

  • Consider the application and the technology involved.
  • Think about testing requirements.
  • Determine license cost of the tool.
  • Evaluate the skill sets available within your organization.

8. Can you explain the Selenium Framework which you have used in your project?

Answer:  When we give any answer in the interview the one and only important thing we need to keep in mind is It should be brief and to the point so that interviewer should not lose interest from our answer.

So whenever we need to give answer about framework we can divide framework in terms of different components which we are using to build a structure which we called a framework and which we use in our company

We can start like mentioned below.

1. We are using Page Object with Page Factory framework with functional/structural implementation.

Make sure you know what functional/structural implementation in this framework.

2. We are using standardized maven project for build, execution & dependency management.

Make sure you know about a build tool like ant/maven

3. Language and IDE:  We are using JAVA/Ruby as our binding language and eclipse as IDE. We use java because it is known to most people when we started automation.

4. Action Driver - We also have library package to maintain common functions related to All action method/Selenium/waits/directory creations etc

5. We also have a base page class for common functions use by all pages – to load config.properties file and Web Driver initialization.

Make sure you know why we have Base Page class in page object

5. We have maintained a page class for every page in our application and a page test class to maintain test for that pages. E.g. Product listing page, Add to cart page, Payment page, Invoice generation page.

Make sure you know we maintain different page and all different annotations in page factory

Page Objects Package- com.mystore.pageobjects

Page Class – AddToCart.java

6. We have maintained separate package for page test e.g.

Test Package - com.mystore.testcases

Test Class – AddToCartTest.java

Note:  Maintaining different packages is always a good practice to follow.

7. Utility component - Extent Class, Log4j class, Listeners, Data Providers

Package Name: com.mystore.utility

8. For handling data driven cases we are passing data using xlsx file/xls file /csv file.

>> Make sure you know about libraries like openCSV,JXL/APACHE POI/Java Properties class

9. For ordering tests we are using testng framework.

Make sure you know how to use different annotations and run testng.xml using maven

10. We are using log4j library to maintain logging of our project. We are using all kinds of logging statements like INFO, DEBUG, and ERROR etc. We have maintained a separate class for it in com.mystore.utility package

>> Make sure you know this library usage in java, we can use log4j by mentioning properties of this framework in a xml file or a properties file and putting that file on build path.

11. We are using Extent Report for reporting purpose. It is a third party report and it is easily available at maven central repo.

We are using maven postman plugin / JAVA API to send generated extent reports as an attachment to client Distribution list.

>> Make sure you know about this plugin of maven or Java API

12. We check in our code into client repository using a version controlling tool git bash on windows system.

13. CI tool - We have integrated our project with CI tool i.e. Jenkins to run the build automatically.

Summary: - We should talk about all major components in our project like Logging, Emailing, Page Objects, Page Factory Annotations, TestNG, Exception Handling, Build tool, Version controlling tool, DataDriven usage etc.

10. How you build object repository in your project framework?

Answer: page object model using page factory

11. What is Test Driven Development (TDD) Framework?

Answer: Test-Driven Development is a testing methodology or a programming practice implemented from a developer’s perspective. In this technique, a QA engineer starts designing and writing test cases for every small functionality of an application. The purpose of TDD is to make the code clearer, simple and bug-free.

TDD instructs developers to write new code only if an automated test has failed. This avoids duplication of code. The full form of TDD is Test-driven development.

The simple concept of TDD is to write and correct the failed tests before writing new code (before development). This helps to avoid duplication of code as we write a small amount of code at a time in order to pass tests. (Tests are nothing but requirement conditions that we need to test to fulfill them).

TDD Cycle

Test-Driven development is a process of developing and running automated test before actual development of the application. Hence, TDD sometimes also called as Test First Development.

12. What is Behavior Driven Development (BDD) Framework?

Answer: Behavior -Driven Development (BDD) is a testing approach derived from the Test-Driven Development (TDD) methodology. In BDD, tests are mainly based on systems behavior. This approach defines various ways to develop a feature based on its behavior. In most cases, the Given-When-Then approach is used for writing test cases. Let’s take an example for better understanding:

  • Given the user has entered valid login credentials
  • When a user clicks on the login button
  • Then display the successful validation message

The simple language used in the scenarios helps even non-technical team members to understand what is going on in the software project. This helps and improves communication among technical and non-technical teams, managers, and stakeholders.

Behavior Driven Development (BDD) framework is a software development process that is an offshoot of Test Driven Development (TDD) framework.  BDD is an agile testing methodology. It is the process of development, based on test-driven development and domain-driven.

13. What are the main traits of a good Software Test Automation framework?

Answer: Below are some of the key parameters that a software tester needs to keep in mind, while developing a test automation framework.

  • Handle scripts and data separately.
  • Create libraries.
  • Follow coding standards.
  • Offer high extensibility.
  • Less maintenance
  • Script/Framework version control

Tips:

  • Proper knowledge of Programming language concept
  • Write page classes for all the pages
  • Test Classes may be differ based on the requirements
  • Write validations (Assertions) in the test class only
  • Write the user actions In Page class only
  • Use proper waiting mechanism in page class (user actions) only
  • Usage of proper Naming convention 
  • Always add the comments when you create new class
  • All test cases should be independent as possible

14. Where you have applied OOPS in Automation Framework?

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=v0Yz8mXQA18&list=PLsGOlyTzNH6dQREgTsqPy6C79wWyouEcu&index=10

15. How do you accommodate project specific method in your framework?

Answer: 1st go through all the manual test cases and identify the steps which are repeating. Note down such steps and make them as methods and write into ProjectSpecificLibrary.

16. Where you encounter synchronization in your project?

Answer:  Synchronization is a mechanism which involves two or more components working parallel with each other. Usually, in test automation, there will be two components such as application under test and the test automation tool. Both of them will have specified speeds and the test scripts should be written in a way such that both these components will work with same speed. This will help to avoid “Element Not Found” error which otherwise will consume more time to clear off.

https://www.automationtestinginsider.com/2020/02/waits-in-selenium-webdriver.html

17. Which Test Automation Framework you are using and why?

Answer: Please refer question#8

18. Mention the name of the Framework which you are using currently in your project, explain it in details along with its benefits?

Answer:  Please refer question#8

19. Mention the name of the Framework which you have hands on experience?

Answer:  Please refer question#8

20. Can you explain the Selenium framework which you have used in your project?

Answer: Please refer question#8

21. Where did you implement hashmap concept in framework

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=KAYzkFKlGaQ&list=PLsGOlyTzNH6dQREgTsqPy6C79wWyouEcu&index=9

Project github link: https://github.com/hverma22/MyProject.git

22. Why we are using constructor in framework

Answer: To initialize the page objects in page class

24. Where to use abstract class in framework

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=v0Yz8mXQA18&list=PLsGOlyTzNH6dQREgTsqPy6C79wWyouEcu&index=10

25. Which files can be used as data source for different frameworks?

Answer: Some of the file types of the dataset can be: Excel xml, text, csv, etc.

26. How can I read test data from Excel files?

Answer:  Please refer below YouTube video

https://www.youtube.com/watch?v=isEQPMuB4YU&list=PLsGOlyTzNH6dhM1NCjkbfMTXg-hXnjeqd

27. What is the difference between POI and JXL Jars?

Answer:  Difference between JXL and POI is that Java JXL does not support the Excel 2007+ ". xlsx" format; it only supports ". xls" format. Apache POI supports both with a common design.

28. What is Page Object Model (POM) and its advantages?

Answer: Page Object Model

Page Object Model is a design pattern to create Object Repository for web UI elements. Under this model, for each web page in the application, there should be corresponding page class. This Page class will find the Web Elements of that web page and also contains Page methods which perform operations on those Web Elements.

Advantages

  • Object Repository: You can create an Object Repository of the fields segmented page-wise. This as a result provides a Page Repository of the application as well. Each page will be defined as a java class.
  • Functional Encapsulation: All possible functionality or operations that can be performed on a page can be defined and contained within the same class created for each page. This allows for clear definition and scope of each page's functionality.
  • Low maintenance: Any User Interface changes can swiftly be implemented into the interface as well as class.
  • Programmer Friendly: Robust and more readable. The Object-oriented approach makes the framework programmer friendly.
  • Low Redundancy: Helps reduce duplication of code. If the architecture is correctly and sufficiently defined, the POM gets more done in less code.
  • Efficient & Scalable: Faster than other keyword-driven/data-driven approaches where Excel sheets are to be read/written.

29. What is Page Factory?

Answer: Page Factory is a class provided by Selenium WebDriver to support Page Object Design patterns. In Page Factory, testers use @FindBy annotation. The initElements method is used to initialize web elements. @FindBy: An annotation used in Page Factory to locate and declare web elements using different locators.

30. What is the difference between Page Object Model and Page Factory?

Answer:  Page Object Model (POM) and Page Factory have following differences:

A Page Object Model is a test design pattern which says organizes page objects as per pages in such a way that scripts and page objects can be differentiated easily. A Page Factory is one way of implementing PageObject Model which is inbuilt in selenium.

  • In POM, you define locators using ‘By’ while in Page Factory, you use FindBy annotation to define page objects.
  • Page Object Model is a design approach while PageFactory is a class which provides implementation of Page Object Model design approach.
  • POM is not optimal as it does not provide lazy initialization while Page Factory provides lazy initialization.
  • Plain POM will not help in StaleElementReferecneException while Page Factory takes care of this exception by relocating web element every time whenever it is used.
  • In plain page object model, you need to initialize every page object individually otherwise you will encounter NullPointerException while In PageFactory all page objects are initialized (Lazily) by using initElements() method.

31. What are the advantages of Page Object Model?

Answer: Covered in question#28

32. In POM how to pass value from 1 page to another page?

Answer: Passing another page object:

Try to initiate the page objects in your test and use it from there. To do that just don't return the DashboardPage object from the submit method.

33. Explain what is a data driven framework?

Answer: Data-driven is a test automation framework which stores test data in a table or spreadsheet format. This allows automation engineers to have a single test script which can execute tests for all the test data in the table.

Why Data Driven Testing?

Look at the following Example:

We want to test the login system with multiple input fields with 1000 different data sets.

To test this, you can take following different approaches:

Approach 1) Create 1000 scripts one for each data-set and runs each test separately one by one.

Approach 2) manually change the value in the test script and run it several times.

Approach 3) Import the data from the excel sheet. Fetch test data from excel rows one by one and execute the script.

In the given three scenarios first two are laborious and time-consuming. Therefore, it is ideal to follow the third approach. Thus, the third approach is nothing but a Data-Driven framework.

34. Explain what is a keyword driven framework?

Answer: In keyword driven testing, the keywords that are developed represent an action. A list of keywords maintained in sequence form a test case. Thus a keyword once developed can be used in multiple test scripts.

35. How can you prepare customized HTML report using TestNG in hybrid framework?

Answer: Please refer question#12 from below link

https://www.automationtestinginsider.com/2019/10/selenium-questions-part7-testng.html

36. How can you generate HTML report from your test scripts?

37. Write the code for Reading and Writing to Excel through Selenium?

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=isEQPMuB4YU&list=PLsGOlyTzNH6dhM1NCjkbfMTXg-hXnjeqd

38. How do you use Map Collections in your Selenium Project (Give some examples) ?

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=KAYzkFKlGaQ&list=PLsGOlyTzNH6dQREgTsqPy6C79wWyouEcu&index=9

39. How do you read and write into a PDF file?

40. What is the folder structure of your framework and explain each folder?

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=iFEoctz-wy4&list=PLsGOlyTzNH6dQREgTsqPy6C79wWyouEcu&index=1

41. What do you use for reporting in your Selenium Project?

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=eYVirg_ZuJk&list=PLsGOlyTzNH6dQREgTsqPy6C79wWyouEcu&index=7

42. What is a Data Provider and what is its return type?

Answer: Data provider returns a two-dimensional JAVA object to the test method and the test method, will invoke M times in a M*N type of object array. For example, if the DataProvider returns an array of 2*3 objects, the corresponding testcase will be invoked 2 times with 3 parameters each time.

43. How to create the reusable methods for reading the data from the Excel files?

Answer: Refer Complete excel library

44. How to create the reusable methods for reading the data from the XML files?

45. What is an interface and where you have used in your Framework?

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=v0Yz8mXQA18&list=PLsGOlyTzNH6dQREgTsqPy6C79wWyouEcu&index=10

46. Draw the architecture of a framework implementing Page Object Model and its uses?

Answer: Please refer below YouTube video

https://www.youtube.com/watch?v=iFEoctz-wy4&list=PLsGOlyTzNH6dQREgTsqPy6C79wWyouEcu&index=1

47. Why do we go for Page Object Model (POM) and what is its purpose?

Answer: POM is a design pattern which is commonly used in Selenium for Automating the Test Cases. The Page object is an object-oriented class which acts as an interface for the page of your Application under test. Page class contains web elements and methods to interact with web elements.

48. What have you done to improve the performance of selenium framework?

Or How to Make Selenium WebDriver Scripts Faster

Answer: There are multiple things that can improve the Selenium WebDriver scripts speed:

  • use fast selectors
  • use fewer locators
  • create atomic tests
  • dont test the same functionality twice
  • write good tests
  • use only explicit waits
  • use the chrome driver
  • use drivers for headless browsers
  • re-use the browser instance
  • run scripts in parallel
  • use HTTP parse libraries
  • pre-populate cookies
  • do not load images in the web page

49. We have heard about frameworks well it can be broadly classified into these TDD, BDD and ATDD frameworks .What’s the Difference?

Answer: Few, Differences between TDD BDD and ATDD

  • TDD is a development technique that focuses more on the implementation of a  feature.
  • BDD focuses on the behavioral aspect of the system rather unlike the TDD focuses on the implementation aspect of the system.
  • Acceptance Test-Driven Development is very similar to Behavioral-Driven Development. However, a key difference between them is: BDD focuses more on the behavior of the feature, whereas ATDD focuses on capturing the accurate requirements.

50. What is the difference between data driven and modular frameworks?

Answer: Modular: In modular frameworks, the application can be divided into different modules which can be tested independently. Data-Driven Framework: In data-driven frameworks, test data is separated from test scripts and stored in an external resource such as text file, excel spreadsheet, CSV file or database table.

Please refer below YouTube video:



No comments:

Post a Comment