Selenium, Cypress and Playwright

Kishor Munot
4 min readJun 5, 2023

--

Selenium or Playwright or Cypress

Hello Readers,

The agile development methodology focuses on the rapid and speedy delivery of the software in a phased manner. The agile methodology recommends testing should be on a sprint basis. Rather than testing the entire application in one go, the tester should focus more on testing the individual components than the entire system. Manual testing is time-consuming; the same test cases need to be tested multiple times as part of the testing strategy.

However, manual testing is a highly important but little difficult task considering the timeline and promised deadline. Though the development and deployment are faster, sometimes manual testing delays the delivery of the product. The best solution for this is is integrate automation testing with the manual testing in your sprints.

We are going to discuss about Selenium, Cypress and Playwright today. While various testing tools are available in the market, Selenium has been a well-established player for quite some time.However, newer automation testing frameworks such as Cypress and Playwright have recently provided Selenium with serious competition. I have used Selenium and Cypress, and recently started using Playwright so sharing some understanding through this blog.

tool is giving us many amazing things.

Please read this blog before proceeding as it is very important before 
starting the beautiful journey.

Selenium-Cypress-Playwright Architecture

Selenium uses the WebDriver API to interact between the web browsers and browser drivers. The browser driver is specific to the browser, and it is platform dependent. Selenium uses JSON to translate test cases before sending them to the browser. Then the command is executed on the browser, receiving the response back using the HTTP protocol. However, recent Selenium version 4 changed its architecture and replaced the JSON wire protocol with W3C standards, which sends and receives the request using the HTTP protocol.

Cypress is not flaky. Cypress commands run in the browser, It has great control over the DOM. Cypress knows and understands everything that happens in the application synchronously. Cypress even knows how fast an element is animating and will wait for it to stop! Additionally, it automatically waits for elements to become visible, to become enabled, and to stop being covered. When pages begin to transition, Cypress will pause command execution until the subsequent page is fully loaded.As several architecture layers as Selenium do not have Cypress. It works in a browser in the same way. That’s why we see a significant improvement over selenium in the speed of test performance.

Playwright works directly with the WebSocket, which means once you trigger the test, the code will be converted into JSON format and will be sent to the server using Web socket protocol. Once the connection or handshake connection is established, commands are sent between your test and the Playwright server. Client and server connections will remain active until one or both parties discontinue them. After closing the connection, the connection is terminated from both ends. One of the reasons that Playwright is fast is because the connection stays active as long as neither party terminates it.

Selenium Vs Cypress Vs Playwright
​​A test is considered flaky when it can pass and fail across multiple 
retry attempts without any code changes.
As one of the Google blogs says – ​​Almost 16% of our tests have some flakiness
associated with them! This is a staggering number;more than 1 in 7 of the
tests written by our world-class engineers occasionally fail in a way not
caused by changes to the code or tests.

In one of the research, it was found that 72 percent of test failures are
false positives. Think about all the tests you have and all the test failures
reported for each run. False positives consume a lot of resources that could
be dedicated to much more valuable work..

We discussed about major tools used for automation testing. Ultimately, the best tool for your organization will depend on your specific testing needs and requirements. Selenium,Cypress and Playwright are worth considering if you need to automate browser testing for your web applications. At last we should integrate our manual and automation testing together and minimize major blocker issues in the product we release for customers.

Share your valuable feedback with us.

Thank you.

Here to make the community stronger by sharing our knowledge. Follow me and my team to stay updated on the latest and greatest in the web & mobile tech world.

--

--