Posts

Showing posts from June, 2021

How to mock a response in Selenium

Image
 First, let us understand why there is a need to mock?  UI automation is an expensive thing to do as it's flaky and time-consuming not only in development but as well as in execution. Use Case 1 Imagine a situation, where we have an e-Commerce application where there is a new rating and review functionality. Now, in order to test this functionality, I need a lot of variations of test data from 0 reviews and ratings to probably a higher number. If I have to automate this scenario, that means, I need to  create multiple users Add their basic details such as Address, payments, etc Add that particular product in all the multiple users who will give ratings and reviews And finally, add ratings and reviews To achieve the above, we have 2 options 1. Using API's  directly and follow the above steps 2. Mock the response of the API which is getting these ratings and reviews details. If you are using Cypress, it is very much possible. todo using their intercept command. For Se...