# JavaScript browser automation libraries

JavaScript browser automation libraries control a web browser from code to open pages, click, type, and read content. Each command travels to the browser over a protocol such as WebDriver BiDi or the Chrome DevTools Protocol. These libraries run end-to-end tests, scrape pages that need JavaScript, and give AI agents a browser they can operate.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [playwright-core](#playwright-core) | 712.5M | 100.6K | Nov 2026 | Apache-2.0 |
| [puppeteer-core](#puppeteer-core) | 127.0M | 95.9K | Nov 2026 | Apache-2.0 |
| [WebDriver](#webdriver) | 13.2M | 9.9K | Nov 2026 | MIT |
| [webdriverio](#webdriverio) | 12.8M | 9.9K | Nov 2026 | MIT |
| [chrome-remote-interface](#chrome-remote-interface) | 12.5M | 4.6K | Feb 2026 | MIT |
| [Stagehand](#browserbasehq-stagehand) | 10.2M | 26.1K | Nov 2026 | MIT |
| [selenium-webdriver](#selenium-webdriver) | 8.2M | 34.6K | Nov 2026 | Apache-2.0 |
| [testcafe](#testcafe) | 853.8K | 9.9K | Oct 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[playwright-core](#playwright-core) has the most monthly downloads in this comparison, at 712.5M.

## Capabilities

| Library | Locator action auto-wait | Native model-guided actions |
| --- | --- | --- |
| [playwright-core](#playwright-core) | Yes | No |
| [puppeteer-core](#puppeteer-core) | Yes | No |
| [WebDriver](#webdriver) | No | No |
| [webdriverio](#webdriverio) | Yes | No |
| [chrome-remote-interface](#chrome-remote-interface) | No | No |
| [Stagehand](#browserbasehq-stagehand) | Undocumented | Yes |
| [selenium-webdriver](#selenium-webdriver) | No | No |
| [testcafe](#testcafe) | Yes | No |

## Libraries

### playwright-core

[GitHub](https://github.com/microsoft/playwright) · [npm](https://www.npmjs.com/package/playwright-core)

Drives web browsers through a high-level API, without the Playwright Test runner.

- Downloads / mo: 712.5M
- Stars: 100.6K
- Last release: 1.65.1
- License: Apache-2.0
- Capabilities: [From the playwright-core docs](https://github.com/microsoft/playwright)

```sh
npm install playwright-core
```

**executeautomation/mcp-playwright** (5.7K stars)

[executeautomation/mcp-playwright](https://github.com/executeautomation/mcp-playwright) 

```javascript
async execute(args: any, context: ToolContext): Promise<ToolResponse> {
  return this.safeExecute(context, async (page) => {
    const filename = args.filename || 'page.pdf';
    const options = {
      path: path.resolve(args.outputPath || '.', filename),
      format: args.format || 'A4',
      printBackground: args.printBackground !== false,
      margin: args.margin || {
        top: '1cm',
        right: '1cm',
        bottom: '1cm',
        left: '1cm'
      }
    };

    await page.pdf(options);
    return createSuccessResponse(`Saved page as PDF: ${options.path}`);
  });
}

```

[src/tools/browser/output.ts](https://github.com/executeautomation/mcp-playwright/blob/2349c2891e7c499c8c07b7d78c7f3fb4c797a1da/src/tools/browser/output.ts#L12-L30) · [More projects using playwright-core →](https://dashboard.exa.ai/playground/search?q=playwright-core%20GitHub%20projects)

**Quickstart**

```javascript
import { chromium } from "playwright-core";

const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto("https://example.com");
console.log(await page.title());
await browser.close();

```

From [Playwright docs](https://playwright.dev/docs/library)

### puppeteer-core

[GitHub](https://github.com/puppeteer/puppeteer) · [npm](https://www.npmjs.com/package/puppeteer-core)

Controls Chrome over the DevTools Protocol through a high-level API, with the browser installed separately.

- Downloads / mo: 127.0M
- Stars: 95.9K
- Last release: 25.18.1
- License: Apache-2.0
- Capabilities: [From the puppeteer-core docs](https://github.com/puppeteer/puppeteer)

```sh
npm install puppeteer-core
```

**marp-team/marp-cli** (3.9K stars)

[marp-team/marp-cli](https://github.com/marp-team/marp-cli) 

```javascript
private async convertFileToPDF(
  tpl: TemplateResult,
  file: File,
  { postprocess = true }: ConvertPDFOption = {}
): Promise<File> {
  const html = new File(file.absolutePath)
  html.buffer = Buffer.from(tpl.result)

  const ret = file.convert(this.options.output, { extension: 'pdf' })

  // Generate PDF
  let outlineData: OutlineData | undefined

  ret.buffer = Buffer.from(
    await this.usePuppeteer(html, async (page, { render }) => {
      await render()

      if (tpl.rendered.outline) {
        outlineData = await page.evaluate(
          pptrOutlinePositionResolver,
          tpl.rendered.outline.flatMap((o) => o.headings),
          pdfOutlineAttr
        )
      }

      return await page.pdf({
        printBackground: true,
        preferCSSPageSize: true, // This option is not working in WebDriver BiDi
        width: tpl.rendered.size.width,
        height: tpl.rendered.size.height,
      })
    })
  )

  if (postprocess) {
    // Apply PDF metadata and annotations
    const creationDate = new Date()
    const { PDFDocument, PDFHexString, PDFString } = await import('pdf-lib')
    const pdfDoc = await PDFDocument.load(ret.buffer)

    pdfDoc.setCreator(CREATED_BY_MARP)
    pdfDoc.setProducer(CREATED_BY_MARP)
    pdfDoc.setCreationDate(creationDate)
    pdfDoc.setModificationDate(creationDate)

    if (tpl.rendered.title) pdfDoc.setTitle(tpl.rendered.title)
    if (tpl.rendered.description) pdfDoc.setSubject(tpl.rendered.description)
    if (tpl.rendered.author) pdfDoc.setAuthor(tpl.rendered.author)
    if (tpl.rendered.keywords)
      pdfDoc.setKeywords([tpl.rendered.keywords.join('; ')])

    if (this.options.pdfOutlines && tpl.rendered.outline) {
      await setOutline(
        pdfDoc,
        generatePDFOutlines(tpl.rendered.outline, {
          ...this.options.pdfOutlines,
          data: outlineData,
          size: tpl.rendered.size,
        })
      )
    }

    if (this.options.pdfNotes) {
      const pages = pdfDoc.getPages()

      for (let i = 0, len = pages.length; i < len; i += 1) {
        const notes = tpl.rendered.comments[i].join('\n\n')

        if (notes) {
          const noteAnnot = pdfDoc.context.obj({
            Type: 'Annot',
            Subtype: 'Text',
            Rect: [0, 20, 20, 20],
            Contents: PDFHexString.fromText(notes),
            T: tpl.rendered.author
              ? PDFHexString.fromText(tpl.rendered.author)
              : undefined,
            Name: 'Note',
            Subj: PDFString.of('Note'),
            C: [1, 0.92, 0.42], // RGB
            CA: 0.25, // Alpha
          })

          pages[i].node.addAnnot(pdfDoc.context.register(noteAnnot))
        }
      }
    }

    // Apply modified PDF to buffer
    ret.buffer = Buffer.from(await pdfDoc.save())
  }

  return ret
}

```

[src/converter.ts](https://github.com/marp-team/marp-cli/blob/ffc4128626cbc64965fe1cc805717c6d4438c384/src/converter.ts#L333-L426) · [More projects using puppeteer-core →](https://dashboard.exa.ai/playground/search?q=puppeteer-core%20GitHub%20projects)

**Quickstart**

```javascript
import puppeteer from "puppeteer-core";

const browser = await puppeteer.launch({ channel: "chrome" });
const page = await browser.newPage();
await page.goto("https://example.com");
console.log(await page.title());
await browser.close();

```

From [Puppeteer docs](https://pptr.dev/)

### WebDriver

[GitHub](https://github.com/webdriverio/webdriverio) · [npm](https://www.npmjs.com/package/webdriver)

Implements the WebDriver and WebDriver BiDi protocols for Node.js.

- Downloads / mo: 13.2M
- Stars: 9.9K
- Last release: 10.2.0
- License: MIT
- Capabilities: [From the WebDriver docs](https://github.com/webdriverio/webdriverio)

```sh
npm install webdriver
```

**appium/appium-inspector** (1.9K stars)

[appium/appium-inspector](https://github.com/appium/appium-inspector) 

```javascript
static attachToSession(sessionId, serverOpts, capabilities = {}) {
    if (!sessionId) {
      throw new Error("Can't attach to a session without a session id");
    }
    const safeServerOpts = {sessionId, ...DEFAULT_SERVER_PROPS, ...serverOpts, capabilities};
    const sessionClient = webdriver.attachToSession(safeServerOpts);
    return new WDSessionDriver(sessionClient);
  }

```

[app/common/renderer/lib/appium/session-starter.js](https://github.com/appium/appium-inspector/blob/d9a887d75491a49754288c92fb15ecd3d754a90c/app/common/renderer/lib/appium/session-starter.js#L36-L43) · [More projects using WebDriver →](https://dashboard.exa.ai/playground/search?q=webdriver%20GitHub%20projects)

**Quickstart**

```javascript
import WebDriver from "webdriver";

const browser = await WebDriver.newSession({
  capabilities: { browserName: "chrome" },
});
await browser.navigateTo("https://example.com");
console.log(await browser.getTitle());
await browser.deleteSession();

```

From [npm registry](https://registry.npmjs.org/webdriver/10.2.0)

### webdriverio

[GitHub](https://github.com/webdriverio/webdriverio) · [npm](https://www.npmjs.com/package/webdriverio)

Adds browser convenience commands and automatic interaction waits over WebDriver protocols.

- Downloads / mo: 12.8M
- Stars: 9.9K
- Last release: 10.2.0
- License: MIT
- Capabilities: [From the webdriverio docs](https://github.com/webdriverio/webdriverio)

**Strengths**

- **Waits before element interactions.** Click and setValue wait for visible, interactable elements.
- **Works as a standalone library.** Use browser commands from ordinary Node scripts without the test runner.

**Watch out for**

- **Network mocks require BiDi.** Choose a local browser or remote provider that supports WebDriver BiDi.

```sh
npm install webdriverio
```

**serenity-js/serenity-js** (624 stars)

[serenity-js/serenity-js](https://github.com/serenity-js/serenity-js) 

```typescript
private async activeWindowHandle(): Promise<string> {
        try {
            return await this.browser.getWindowHandle();
        }
        catch (error) {
            // If the window is closed by user action Webdriver will still hold the reference to the closed window.
            if (['NoSuchWindowError', 'no such window'].includes(error.name)) {
                const allHandles = await this.browser.getWindowHandles();
                if (allHandles.length > 0) {
                    const handle = allHandles.at(-1);
                    await this.browser.switchToWindow(handle);

                    return handle;
                }
            }
            throw error;
        }
    }

```

[packages/webdriverio/src/screenplay/models/WebdriverIOBrowsingSession.ts](https://github.com/serenity-js/serenity-js/blob/deed21f8008491eb1d9cdcf93bde7301fbe9f0fb/packages/webdriverio/src/screenplay/models/WebdriverIOBrowsingSession.ts#L84-L101) · [More projects using webdriverio →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20using%20webdriverio%20for%20browser%20interaction%20and%20navigation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { remote } from "webdriverio";

const browser = await remote({ capabilities: { browserName: "chrome" } });
await browser.url("https://example.com");
console.log(await browser.getTitle());
await browser.deleteSession();

```

From [README.md](https://github.com/webdriverio/webdriverio/blob/main/packages/webdriverio/README.md)

### chrome-remote-interface

[GitHub](https://github.com/cyrus-and/chrome-remote-interface) · [npm](https://www.npmjs.com/package/chrome-remote-interface)

Sends Chrome DevTools Protocol commands to a running Chrome target.

- Downloads / mo: 12.5M
- Stars: 4.6K
- Last release: 0.34.0
- License: MIT
- Capabilities: [From the chrome-remote-interface docs](https://github.com/cyrus-and/chrome-remote-interface)

```sh
npm install chrome-remote-interface
```

**cyrus-and/chrome-har-capturer** (572 stars)

[cyrus-and/chrome-har-capturer](https://github.com/cyrus-and/chrome-har-capturer) 

```javascript
async _loadPage(client) {
        // enable domains
        const {Page, Network} = client;
        await Network.enable();
        await Page.enable();
        // register events
        const stats = new Stats(this._url, this._options);
        const termination = new Promise((fulfill, reject) => {
            client.on('event', (event) => {
                stats.processEvent(fulfill, reject, event);
            });
            // XXX the separation of concerns between live fetching and HAR
            // computation made it necessary to introduce a synthetic event
            // which is the reply of the Network.getResponseBody method
            if (this._options.content) {
                Network.loadingFinished(async ({requestId}) => {
                    // only for those entries that are being tracked (e.g., not
                    // for cached items)
                    if (!stats.entries.get(requestId)) {
                        return;
                    }
                    try {
                        const params = await Network.getResponseBody({requestId});
                        const {body, base64Encoded} = params;
                        stats.processEvent(fulfill, reject, {
                            method: 'Network.getResponseBody',
                            params: {
                                requestId,
                                body,
                                base64Encoded
                            }
                        });
                    } catch (err) {
                        // sometimes it is impossible to fetch the content (see #82)
                        stats.processEvent(fulfill, reject, {
                            method: 'Network.getResponseBody',
                            params: {
                                requestId
                            }
                        });
                    }
                });
            }
        });
        // start the page load
        const navigation = Page.navigate({url: this._url});
        // events will determine termination
        await Promise.all([termination, navigation]);
        return stats;
    }

```

[lib/live.js](https://github.com/cyrus-and/chrome-har-capturer/blob/4b69108c4b8b9071a3cd3491127d655ab86c8c88/lib/live.js#L86-L135) · [More projects using chrome-remote-interface →](https://dashboard.exa.ai/playground/search?q=chrome-remote-interface%20GitHub%20projects)

**Quickstart**

```javascript
import CDP from "chrome-remote-interface";

const client = await CDP();
const { Page, Runtime } = client;
await Page.enable();
const loaded = Page.loadEventFired();
await Page.navigate({ url: "https://example.com" });
await loaded;
const { result } = await Runtime.evaluate({ expression: "document.title" });
console.log(result.value);
await client.close();

```

From [README.md](https://github.com/cyrus-and/chrome-remote-interface)

### Stagehand

[GitHub](https://github.com/browserbase/stagehand) · [npm](https://www.npmjs.com/package/@browserbasehq/stagehand)

Builds browser agents on Browserbase's SDK, with model-guided page actions.

- Downloads / mo: 10.2M
- Stars: 26.1K
- Last release: 4.4.0
- License: MIT
- Capabilities: [From the Stagehand docs](https://github.com/browserbase/stagehand)

```sh
npm install @browserbasehq/stagehand
```

**Quickstart**

```javascript
import { localBrowser, Stagehand } from "@browserbasehq/stagehand";

const browser = await localBrowser.launch({ userDataDir: "./browser-data" });
const stagehand = await Stagehand.create({
  browser,
  model: { modelName: "openai/gpt-5.4-mini", apiKey: process.env.OPENAI_API_KEY },
});
const [page] = await browser.context.pages();
await page.goto("https://example.com");
const { data } = await stagehand.observe("find the main heading");
console.log(data);
await stagehand.close();
await browser.close();

```

From [README.md](https://github.com/browserbase/stagehand) · [Find projects using Stagehand →](https://dashboard.exa.ai/playground/search?q=%40browserbasehq/stagehand%20GitHub%20projects)

### selenium-webdriver

[GitHub](https://github.com/SeleniumHQ/selenium) · [npm](https://www.npmjs.com/package/selenium-webdriver)

Provides JavaScript bindings for local and remote WebDriver browser automation.

- Downloads / mo: 8.2M
- Stars: 34.6K
- Last release: 4.53.0
- License: Apache-2.0
- Capabilities: [From the selenium-webdriver docs](https://github.com/SeleniumHQ/selenium)

**Strengths**

- **Configures different installed browsers.** Use Builder to choose the browser and apply its options.
- **Connects to remote WebDriver servers.** Point Builder at Selenium Grid or a standalone server.

**Watch out for**

- **Loaded pages can still change.** Wait for the element or condition the next action requires.

```sh
npm install selenium-webdriver
```

**sitespeedio/browsertime** (653 stars)

[sitespeedio/browsertime](https://github.com/sitespeedio/browsertime) 

```typescript
export async function createWebDriver(baseDir, options, tmpDir) {
  const browser = options.browser || 'chrome';
  const seleniumUrl = options.selenium ? options.selenium.url : undefined;
  const capabilities = options.selenium
    ? options.selenium.capabilities
    : undefined;

  const builder = new Builder()
    .forBrowser(browser === 'edge' ? 'MicrosoftEdge' : browser)
    .usingServer(seleniumUrl);

  // Hack for running browsertime on different platforms.
  // Keep it in the dark for now becasue if you don't know
  // what you do, a lot can get wrong
  if (!isEmpty(capabilities)) {
    builder.withCapabilities(capabilities);
  }

  switch (browser) {
    case 'chrome': {
      await configureBuilderChrome(builder, baseDir, options, tmpDir);
      break;
    }

    case 'firefox': {
      await configureBuilderFirefox(builder, baseDir, options);
      break;
    }

    case 'safari': {
      await configureBuilderSafari(builder, baseDir, options);
      break;
    }

    case 'edge': {
      await configureBuilderEdge(builder, baseDir, options, tmpDir);
      break;
    }

    default: {
      throw new Error('Unsupported browser: ' + browser);
    }
  }

  return builder.build();
}

```

[lib/core/webdriver/index.js](https://github.com/sitespeedio/browsertime/blob/fe504d994f601b30759c449e6f990e2afc261eb0/lib/core/webdriver/index.js#L14-L59) · [More projects using selenium-webdriver →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20using%20selenium-webdriver%20for%20browser%20interaction%20and%20navigation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
const { Builder, Browser } = require("selenium-webdriver");

(async function main() {
  const driver = await new Builder().forBrowser(Browser.CHROME).build();
  try {
    await driver.get("https://example.com");
    console.log(await driver.getTitle());
  } finally {
    await driver.quit();
  }
})();

```

From [npm registry](https://registry.npmjs.org/selenium-webdriver/4.53.0)

### testcafe

[GitHub](https://github.com/DevExpress/testcafe) · [npm](https://www.npmjs.com/package/testcafe)

Runs automated browser tests for web applications.

- Downloads / mo: 853.8K
- Stars: 9.9K
- Last release: 3.7.7
- License: MIT
- Capabilities: [From the testcafe docs](https://github.com/DevExpress/testcafe)

```sh
npm install testcafe
```

**codeceptjs/CodeceptJS** (4.3K stars)

[codeceptjs/CodeceptJS](https://github.com/codeceptjs/CodeceptJS) 

```javascript
async _startRemoteBrowser(runner) {
    const remoteConnection = await this.testcafe.createBrowserConnection()
    console.log('Connect your device to the following URL or scan QR Code: ', remoteConnection.url)
    qrcode.generate(remoteConnection.url)
    remoteConnection.once('ready', () => {
      runner
        .src(this.dummyTestcafeFile)
        .browsers(remoteConnection)
        .reporter('minimal')
        .run({
          selectorTimeout: this.options.waitForTimeout,
          skipJsErrors: true,
          skipUncaughtErrors: true,
        })
        .catch(err => {
          this.debugSection('_before', `Error ${err.toString()}`)
          this.isRunning = false
          this.testcafe.close()
        })
    })
  }

```

[lib/helper/TestCafe.js](https://github.com/codeceptjs/CodeceptJS/blob/a931bde80b08fd1ac83bb223779962a26493da98/lib/helper/TestCafe.js#L196-L216) · [More projects using testcafe →](https://dashboard.exa.ai/playground/search?q=testcafe%20GitHub%20projects)

**Quickstart**

```javascript
fixture `Example`.page `https://devexpress.github.io/testcafe/example`;

test('type a name', async t => {
  await t.typeText('#developer-name', 'Ada');
});

```

From [npm registry](https://registry.npmjs.org/testcafe/3.7.7)

## FAQ

### Playwright vs Selenium: what is the difference?

[Playwright](#playwright-core) locators wait until an element is ready before acting. [Selenium WebDriver](#selenium-webdriver) leaves waits to the test code and drives browsers through the WebDriver protocol, locally or on Selenium Grid.

### Playwright vs Puppeteer: what is the difference?

[Puppeteer](#puppeteer-core) controls Chrome and Firefox and can attach to a running browser endpoint. [Playwright](#playwright-core) drives several browsers through one API and checks each element's actionability before an action.

### Stagehand vs Playwright: how do they differ?

[Stagehand](#browserbasehq-stagehand) adds model-guided actions, where a language model decides how to act on the page. [Playwright](#playwright-core) runs only the actions the code specifies.

### Do Puppeteer locators automatically wait before clicking?

Locators wait for the element to be present and in the right state for the action. The checks include viewport, visibility, enabled state, and a stable bounding box.

### Does Playwright remote connect accept any server version?

The connecting client and browser-launching Playwright instance must have matching major and minor versions.

### Can every remote WebdriverIO session mock network requests?

Network mocking in WebdriverIO requires WebDriver BiDi support in the browser or remote provider.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript browser automation libraries Playwright Puppeteer Selenium WebDriver WebdriverIO code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
