October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Automate Electron Apps with Selenium WebDriver

Automate an Electron renderer with Selenium by starting a compatible ChromeDriver, configuring its server URL and Electron executable, and closing the WebDriver session reliably.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can automate an Electron app’s renderer UI with Selenium WebDriver and ChromeDriver. The key difference from ordinary browser automation is that you must connect Selenium to the running ChromeDriver server and tell ChromeDriver which Electron executable to launch. Match the driver to your Electron release, use the correct executable path for your build and operating system, and shut the WebDriver session down when the test ends.

What you need for Selenium automation

  • An Electron app build to test and its Electron executable path.
  • Node.js, the selenium-webdriver package, and an Electron-compatible ChromeDriver. Electron’s guide uses the electron-chromedriver package.
  • A ChromeDriver process listening at an address your Selenium test can reach. The Electron guide’s example uses http://localhost:9515; the address in your builder must match the server’s actual address and port.

Electron’s automated-testing guide says Selenium usage is like testing a normal website, except that you manually specify how to connect to ChromeDriver and where the Electron binary is. See the Electron automated-testing guide.

Install and align the packages

In your project, install Selenium WebDriver and Electron’s ChromeDriver package:

npm install --save-dev selenium-webdriver electron-chromedriver

The Electron-maintained electron/chromedriver repository describes electron-chromedriver as downloading ChromeDriver for Electron and says its major version tracks the Electron major version. Select and verify a release compatible with the Electron version your project actually uses; do not copy an old version number from a documentation sample.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Electron’s guide prints ChromeDriver v2.10.291558 in an example terminal session. That is historical sample output, not a current recommendation. Likewise, 9515 is the guide’s example port, not a requirement. Confirm which driver executable your installed package provides and how it should be started for that version and project setup.

Start ChromeDriver and connect Selenium to Electron

Start the ChromeDriver executable supplied for your Electron-compatible setup, then build a Selenium session using the same server URL and the actual Electron executable path. The following is the connection pattern documented by Electron:

const webdriver = require('selenium-webdriver')

const driver = new webdriver.Builder()
  .usingServer('http://localhost:9515')
  .withCapabilities({
    'goog:chromeOptions': {
      binary: '/path/to/your/Electron-app-executable'
    }
  })
  .forBrowser('chrome')
  .build()

Replace the binary value with the executable for the app build under test. The macOS path shown in Electron’s guide is an example, not a portable path: locate the executable inside your own packaged app or development build. Keep the usingServer() URL aligned with the host and port where ChromeDriver is listening.

The guide notes that .forBrowser('electron') applied only to selenium-webdriver versions at or below 3.6.0. For current work, follow the API for the version of selenium-webdriver installed; do not copy that historical browser-name setting into a newer setup without checking its compatibility.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Write a test, wait for the UI, and clean up

Once the session is built, use WebDriver commands to navigate and interact with the app’s renderer, just as you would with a webpage. Replace the sample URL, selector, and expected text with elements and behavior that exist in your application.

const { By, until } = require('selenium-webdriver')

async function runTest() {
  const driver = new webdriver.Builder()
    .usingServer('http://localhost:9515')
    .withCapabilities({
      'goog:chromeOptions': {
        binary: '/path/to/your/Electron-app-executable'
      }
    })
    .forBrowser('chrome')
    .build()

  try {
    await driver.get('file:///path/to/your/app-page.html')
    const heading = await driver.wait(
      until.elementLocated(By.css('h1')),
      10000
    )
    console.log(await heading.getText())
  } finally {
    await driver.quit()
  }
}

runTest().catch(error => {
  console.error(error)
  process.exitCode = 1
})

This is a basic structure, not a universal Electron launch recipe: use the navigation target and selectors appropriate to the app and test environment. The important lifecycle points are to wait for the condition your test needs and to call driver.quit() even when an assertion or interaction fails, so the WebDriver session is closed.

Understand Selenium Manager’s role

Selenium documents WebDriver as its core browser-automation interface. Its documentation describes Selenium Manager as automating driver and browser management for Selenium bindings by default: Selenium documentation. Electron’s guide, however, separately calls for an Electron binary path and Electron-oriented ChromeDriver configuration. The cited guidance does not establish that Selenium Manager automatically resolves Electron/ChromeDriver compatibility or launches your app, so retain and verify those Electron-specific settings.

When to choose another Electron test framework

If you are choosing a stack rather than extending an existing Selenium suite, compare whether tests must launch and shut down the app, access Electron APIs beyond renderer interactions, and support the project’s Electron release. Electron’s automated-testing documentation also covers these options:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option What the cited Electron documentation establishes Relevant consideration
Selenium WebDriver Connect to ChromeDriver and provide the Electron binary path. Useful when your tests use Selenium, but preserve the explicit driver and binary configuration.
WebdriverIO Electron’s guide covers a workflow that can launch and shut down the app and expose Electron APIs to tests. Consider it when app lifecycle management or Electron API access is central to the test suite.
Playwright Electron describes its support as experimental and says it uses Electron’s Chrome DevTools Protocol support. Evaluate the experimental status against your compatibility and stability needs.
Spectron The repository is explicitly marked deprecated; its README describes its historical Application wrapper and limitations. Legacy context for maintaining an existing suite, not a default for new work.

See the Spectron repository for its deprecation notice. Avoid selecting it for a new test suite.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common setup failures

Selenium cannot connect to ChromeDriver

Check that ChromeDriver is running and that the host and port in usingServer() match its listening address. If the driver is not listening on localhost or uses a different port, update the builder URL accordingly.

The app does not start or the wrong app opens

Verify that goog:chromeOptions.binary points to the executable itself for the build under test, not merely the containing directory or an assumed path copied from another operating system. Use the app’s actual packaged or development executable.

Driver and Electron are incompatible

Check the Electron version in the project and the compatible electron-chromedriver release. The package’s major version tracks Electron’s major version; do not rely on the old ChromeDriver version printed in the guide’s sample output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The test fails before an element appears

Confirm that the test navigates to a page or app route that exists in its environment, then wait for a meaningful UI condition rather than assuming the renderer is ready immediately. Use selectors that match the app’s rendered DOM.

Processes remain after a failing test

Put test actions in a try block and call driver.quit() from finally. This ensures Selenium attempts to close the session regardless of whether a wait or assertion fails.

Or skip the browser setup

If your goal is to capture a website rather than test an Electron app’s interactive renderer, ScreenshotNeo provides a one-request screenshot API and an MCP server for AI agents. It is not a replacement for Selenium-based Electron UI tests. A basic capture request is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for setup and options. Before capture, it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of these steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.