Friday, March 10, 2023

A Comparison of Network Interception capabilities between Cypress and Selenium

Both Selenium and Cypress provide network interception capabilities. As the name implies, the capability allows the user to intercept HTTP requests and manipulate the response received for the given response. This is useful when you want to automate UI scenarios where the preconditions and steps required for the expected output can’t be easily produced.

To evaluate this capability I went about automating the 3 scenarios found below,
  • Intercepting and waiting for a network resource attached to a web page to be received to the client side.
  • Intercepting and simulating 400 and 500 errors.
  • Intercepting and changing response payloads.
I found that Cypress provides HTTP level interception while Selenium simulates interception through the Web Driver client. And that interception in general is easier in Cypress. Selenium provides better control over response status code manipulation, but surprisingly selenium doesn’t provide a way to access the HTTP response codes through its client so asserting status code related scenarios may be more troublesome.

Cypress Examples

Selenium Examples


What's in my Bag? EDC of a Tester