Christian Genco

Best library for end-to-end testing: Cypress vs. Puppeteer vs. Playwright vs. Selenium vs. WebDriver

I use Jest.


Cypress #

Run Cypress tests against a Vercel preview deployment:

Puppeteer #

Grab some text from a div:

await page.goto(`${config.get("baseURL")}`);
await page.waitFor("#loadedchild", { visible: true, timeout: 5000 });
const element = await page.$("#loadedchild");
const text = await (await element.getProperty("textContent")).jsonValue();

Playwright #

Playwright lets you record a web session and automatically generate test code in Javascript, Typescript, Java, Python, or C#. It supports the Chromium (which drives Chrome, Edge, and Opera), Firefox, and WebKit browser engines.

The basic setup looks like this:

const browser = await chromium.launch();
// "context" acts as a new incognito window
const context = await browser.newContext();
const page = await context.newPage();

You can take screenshots with await page.screenshot({path: "screenshot.png"}). You can record videos of each session with:

const context = await browser.newContext({
  recordVideo: {
    dir: "videos",

To find an item you use await page.$('id=username').

Playwright also lets you record videos and record authentication state.

Grab some text from a div:

await page.goto(`${config.get("baseURL")}`);
const text = await page.textContent("#loadedchild");

Selenium #

To find an item you use driver.findElement("username")).

const driver = new FirefoxDriver();

Automatically running end-to-end tests on GitHub with each Vercel deployment #