Home  Playwright   Difference ...

difference between playwright, cypress and selenium


1️⃣ Cypress Architecture Overview

Unlike Selenium or Playwright:

Diagrammatically:

Your Test Code (Cypress) 
       │
       ▼
Cypress Test Runner (Node + Browser bundle)
       │
       ▼
Browser DOM / JS
       │
       ▼
Native events / page interactions

2️⃣ How Cypress Click Works Internally

When you do:

cy.get('#login-button').click()

Cypress does:

  1. Find the element in the DOM (it’s actually running inside the browser context).

  2. Scroll element into view.

  3. Dispatch native events using JavaScript, not CDP:

    • mousedown, mouseup, click, focus
  4. Ensure application stability before and after the click (waits for animations, XHR, promises, etc.)

Essentially:

element.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, clientX: 200, clientY: 150 }));
element.dispatchEvent(new MouseEvent('mouseup', { bubbles: true, clientX: 200, clientY: 150 }));
element.dispatchEvent(new MouseEvent('click', { bubbles: true, clientX: 200, clientY: 150 }));

✅ Notice: There is no separate driver or CDP command involved. Cypress is literally controlling the DOM from inside the browser.


3️⃣ Comparison with Selenium / Playwright

FeatureSeleniumPlaywrightCypress
Driver neededYes (chromedriver/geckodriver)NoNo
ProtocolW3C WebDriver → driver → CDPDirect CDP / native protocolNone; runs in-browser JS
Low-level actionInput.dispatchMouseEvent (via driver)Input.dispatchMouseEvent (direct)element.dispatchEvent in JS
Access to browser internalsLimitedFull via CDPLimited to what can be done via JS
Auto-wait / retryManual waits or built-in (Playwright has auto-wait better)Built-in waits, retries, stability checksBuilt-in waits, retries, and DOM stability

4️⃣ Key Takeaways

So yes, all three eventually trigger the same browser behavior (click, type, navigate), but the path and control mechanism differ:


5️⃣ Analogy

AnalogySeleniumPlaywrightCypress
Click a buttonAsk your assistant to press the buttonPress it yourself via a direct wire to the robotYou reach in and press the button yourself

💡 Extra: This is why Cypress cannot control multiple browsers simultaneously, or run remote sessions natively — it’s limited to the browser it’s injected into. Playwright and Selenium can do that because they use external processes/protocols.


Published on: Oct 09, 2025, 02:58 AM  
 

Comments

Add your comment