---
title: Electron Testing in the Cloud
description: Run automated Electron tests in the cloud. Test your Electron app automatically
  across Linux, Windows and macOS operating systems.
source_url:
  html: https://testingbot.com/support/app-automate/electron
  md: https://testingbot.com/support/app-automate/electron/index.md
---
# Electron Testing

[Electron](https://electronjs.org/) is a framework that allows you to create cross-platform native applications by using Javascript code. Electron will embed a Chromium engine in a native app format, allowing web developers to create desktop applications by writing HTML and Javascript code.

TestingBot supports running automated WebDriver tests against Electron-based apps on these platforms:

- Windows 11
- Windows 10
- macOS Tahoe
- macOS Sequoia
- macOS Sonoma
- macOS Ventura
- macOS Monterey

All Electron versions from version 16 to the most recent version are supported.

TestingBot has created a [demo Electron app](https://github.com/testingbot/testingbot-electron-demo-app), which acts as a simple calculator, to showcase automated Electron app testing.

## Run your first Electron test

### App management

To test an Electron app, you'll first need to upload a zip file of your Electron application to a URL where TestingBot can download it from. You can choose to upload this yourself, for example to AWS S3 or use [TestingBot Storage](https://testingbot.com/support/api#upload) to upload your `.zip` file.

Note that files uploaded to TestingBot Storage are automatically pruned after 62 days.

[cURL](https://testingbot.com#)[Ruby](https://testingbot.com#)[Python](https://testingbot.com#)[PHP](https://testingbot.com#)[Java](https://testingbot.com#)[NodeJS](https://testingbot.com#)

    $ curl -X POST "https://api.testingbot.com/v1/storage" \
    -u key:secret -F "file=@/path/to/app/file/electron-app.zip"

    require 'testingbot'
    api = TestingBot::Api.new("key", "secret")
    api.upload_local_file('/path/to/electron-app.zip')

    TestingbotREST restApi = new TestingbotREST("key", "secret");
    TestingbotStorageUploadResponse uploadResponse = restApi.uploadToStorage(new File("/path/to/electron-app.zip"));

    $api = new TestingBot\TestingBotAPI("key", "secret");
    $api->uploadLocalFileToStorage("/path/to/electron-app.zip");

    import testingbotclient
    tb = testingbotclient.TestingBotClient("key", "secret")
    tb.storage.upload_local_file("/path/to/electron-app.zip")

    const TestingBot = require('testingbot-api');
    
    const api = new TestingBot({
      api_key: "your-tb-key",
      api_secret: "your-tb-secret"
    });
    
    api.uploadFile('/path/to/electron-app.zip', function(error, response) {
        // response.app_url
    });

TestingBot Storage will return a `app_url` which you can use in the `tb:app` capability of your test.

This is how the capabilities in your test should currently look like:

[Ruby](https://testingbot.com#)[Python](https://testingbot.com#)[Java](https://testingbot.com#)[NodeJS](https://testingbot.com#)[C#](https://testingbot.com#)

    caps = {
      "browserName" => "electron",
      "browserVersion" => "42",
      "tb:app" => "tb://the-app-url-you-received" # or https://s3.amazonaws.com/...
    }

    ChromeOptions options = new ChromeOptions();
    options.setCapability("browserName", "electron");
    options.setCapability("browserVersion", "42");
    options.setCapability("tb:app", "tb://the-app-url-you-received");
    
    Map<String, Object> tbOptions = new HashMap<>();
    tbOptions.put("key", "api_key");
    tbOptions.put("secret", "api_secret");
    options.setCapability("tb:options", tbOptions);

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    options = Options()
    options.set_capability("browserName", "electron")
    options.set_capability("browserVersion", "42")
    options.set_capability("tb:app", "tb://the-app-url-you-received")
    options.set_capability("tb:options", {
        "name": "Electron Sample"
    })
    
    driver = webdriver.Remote("https://hub.testingbot.com/wd/hub", options=options)

    driver = await new webdriver.Builder().withCapabilities({
        "browserName": 'electron',
        "browserVersion": "42",
        "tb:options": {
            "key": "api_key",
            "secret": "api_secret"
        },
        'tb:app': 'tb://the-app-url-you-received' // or https://s3.amazonaws.com/...
    }).usingServer("https://hub.testingbot.com/wd/hub").build();

    var chromeOptions = new ChromeOptions();
    chromeOptions.BrowserName = "electron";
    chromeOptions.BrowserVersion = "42";
    chromeOptions.PlatformName = "Windows 10";
    
    var tbOptions = new Dictionary<string, object>
    {
        ["key"] = "api_key",
        ["secret"] = "api_secret",
        ["name"] = TestContext.CurrentContext.Test.Name
    };
    
    // Use AddAdditionalOption (Selenium 4) so these vendor caps land at the top level,
    // not nested under goog:chromeOptions like AddAdditionalChromeOption would.
    chromeOptions.AddAdditionalOption("tb:options", tbOptions);
    chromeOptions.AddAdditionalOption("tb:app", "tb://the-app-url-you-received");
    
    driver = new RemoteWebDriver(new Uri("https://hub.testingbot.com/wd/hub"), chromeOptions);

### Binary location

Next to the required `app` capability, you will also need to specify a `tb:binary_location` capability. This is the path to the actual Electron app, so that TestingBot knows which file in the `zip` file is the Electron app.

For example, if your uploaded zip file is structured like this:

    TestingBot-Electron-App.zip
    [testingbot-electron-demo-app.app]
      [Contents]
        [MacOS]
            -- testingbot-electron-demo-app

The `binary_location` capability in this case would be:

    tb:binary_location = "testingbot-electron-demo-app.app/Contents/MacOS/testingbot-electron-demo-app"

Now the capabilities in your test should look like the example below.

[Ruby](https://testingbot.com#)[Python](https://testingbot.com#)[Java](https://testingbot.com#)[NodeJS](https://testingbot.com#)[C#](https://testingbot.com#)

    require 'selenium-webdriver'
    
    options = Selenium::WebDriver::Options.chrome
    options.browser_name = "electron"
    options.platform_name = "TAHOE"
    options.browser_version = "42"
    options.add_option("tb:binary_location", "testingbot-electron-demo-app.app/Contents/MacOS/testingbot-electron-demo-app")
    options.add_option("tb:app", "https://github.com/testingbot/testingbot-electron-demo-app/releases/download/v1.0.0/testingbot-electron-demo-app-darwin-arm64-1.0.0.zip")
    
    http_client = Selenium::WebDriver::Remote::Http::Default.new
    http_client.open_timeout = 200
    http_client.read_timeout = 200
    
    driver = Selenium::WebDriver.for(
        :remote,
        url: "https://key:secret@hub.testingbot.com/wd/hub",
        options: options,
        http_client: http_client)
    
      # Generate two random numbers between 0 and 9
      num1 = rand(0..9)
      num2 = rand(0..9)
    
      # Find elements on the page
      first_number = driver.find_element(id: "btn-#{num1}")
      second_number = driver.find_element(id: "btn-#{num2}")
      plus = driver.find_element(id: 'btn-plus')
      equal = driver.find_element(id: 'btn-equal')
    
      # Perform operations
      first_number.click
      plus.click
      second_number.click
      equal.click
    
      # Get the result
      result_element = driver.find_element(id: 'calc-display')
      result_text = result_element.text
    
      driver.quit
      raise "Test failed" unless (num1 + num2) == result_text.to_i

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.remote.RemoteWebDriver;
    
    import java.net.URL;
    import java.util.Random;
    
    public class SeleniumTest {
    
        public static void main(String[] args) {
            try {
                ChromeOptions options = new ChromeOptions();
                options.setCapability("browserName", "electron");
                options.setCapability("platformName", "TAHOE");
                options.setCapability("browserVersion", "42");
                options.setCapability("tb:binary_location", "testingbot-electron-demo-app.app/Contents/MacOS/testingbot-electron-demo-app");
                options.setCapability("tb:app", "https://github.com/testingbot/testingbot-electron-demo-app/releases/download/v1.0.0/testingbot-electron-demo-app-darwin-arm64-1.0.0.zip");
    
                WebDriver driver = new RemoteWebDriver(
                    new URL("https://key:secret@hub.testingbot.com/wd/hub"),
                    options
                );
    
                // Generate two random numbers between 0 and 9
                Random random = new Random();
                int num1 = random.nextInt(10);
                int num2 = random.nextInt(10);
    
                WebElement firstNumber = driver.findElement(By.id("btn-" + num1));
                WebElement secondNumber = driver.findElement(By.id("btn-" + num2));
                WebElement plus = driver.findElement(By.id("btn-plus"));
                WebElement equal = driver.findElement(By.id("btn-equal"));
    
                firstNumber.click();
                plus.click();
                secondNumber.click();
                equal.click();
    
                WebElement resultElement = driver.findElement(By.id("calc-display"));
                String resultText = resultElement.getText();
    
                // Verify the result
                if ((num1 + num2) != Integer.parseInt(resultText)) {
                    throw new AssertionError("Test failed");
                }
    
                // Quit the driver
                driver.quit();
    
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.chrome.options import Options
    import random
    
    # Set capabilities
    options = Options()
    options.set_capability("browserName", "electron")
    options.set_capability("platformName", "TAHOE")
    options.set_capability("browserVersion", "42")
    options.set_capability("tb:binary_location", "testingbot-electron-demo-app.app/Contents/MacOS/testingbot-electron-demo-app")
    options.set_capability("tb:app", "https://github.com/testingbot/testingbot-electron-demo-app/releases/download/v1.0.0/testingbot-electron-demo-app-darwin-arm64-1.0.0.zip")
    
    # Initialize the WebDriver connection to TestingBot
    driver = webdriver.Remote(
        command_executor="https://key:secret@hub.testingbot.com/wd/hub",
        options=options
    )
    
    try:
        # Generate two random numbers between 0 and 9
        num1 = random.randint(0, 9)
        num2 = random.randint(0, 9)
    
        # Find elements on the page
        first_number = driver.find_element(By.ID, f"btn-{num1}")
        second_number = driver.find_element(By.ID, f"btn-{num2}")
        plus = driver.find_element(By.ID, "btn-plus")
        equal = driver.find_element(By.ID, "btn-equal")
    
        # Perform operations
        first_number.click()
        plus.click()
        second_number.click()
        equal.click()
    
        # Get the result
        result_element = driver.find_element(By.ID, "calc-display")
        result_text = result_element.text
    
        # Verify the result
        assert (num1 + num2) == int(result_text), "Test failed"
    
    finally:
        driver.quit()

    const { Builder, By } = require('selenium-webdriver');
    const { Options } = require('selenium-webdriver/chrome');
    
    (async function example() {
        let driver;
    
        try {
            // Set capabilities
            let caps = {
                browserName: 'electron',
                platformName: 'TAHOE',
                browserVersion: '41',
                'tb:binary_location': 'testingbot-electron-demo-app.app/Contents/MacOS/testingbot-electron-demo-app',
                'tb:app': 'https://github.com/testingbot/testingbot-electron-demo-app/releases/download/v1.0.0/testingbot-electron-demo-app-darwin-arm64-1.0.0.zip'
            };
    
            driver = await new Builder()
                .usingServer('https://key:secret@hub.testingbot.com/wd/hub')
                .withCapabilities(caps)
                .build();
    
            // Generate two random numbers between 0 and 9
            const num1 = Math.floor(Math.random() * 10);
            const num2 = Math.floor(Math.random() * 10);
    
            const firstNumber = await driver.findElement(By.id(`btn-${num1}`));
            const secondNumber = await driver.findElement(By.id(`btn-${num2}`));
            const plus = await driver.findElement(By.id('btn-plus'));
            const equal = await driver.findElement(By.id('btn-equal'));
    
            // Perform operations
            await firstNumber.click();
            await plus.click();
            await secondNumber.click();
            await equal.click();
    
            // Get the result
            const resultElement = await driver.findElement(By.id('calc-display'));
            const resultText = await resultElement.getText();
    
            // Verify the result
            if ((num1 + num2) !== parseInt(resultText)) {
                throw new Error('Test failed');
            }
    
        } catch (error) {
            console.error('Error during test execution:', error);
        } finally {
            if (driver) {
                await driver.quit();
            }
        }
    })();

    using OpenQA.Selenium;
    using OpenQA.Selenium.Chrome;
    using OpenQA.Selenium.Remote;
    using System;
    
    class SeleniumTest
    {
        static void Main(string[] args)
        {
            try
            {
                // Set capabilities
                var options = new ChromeOptions();
                options.BrowserName = "electron";
                options.PlatformName = "TAHOE";
                options.BrowserVersion = "42";
                // Use AddAdditionalOption (Selenium 4) so these vendor caps land at the top level,
                // not nested under goog:chromeOptions like AddAdditionalChromeOption would.
                options.AddAdditionalOption("tb:binary_location", "testingbot-electron-demo-app.app/Contents/MacOS/testingbot-electron-demo-app");
                options.AddAdditionalOption("tb:app", "https://github.com/testingbot/testingbot-electron-demo-app/releases/download/v1.0.0/testingbot-electron-demo-app-darwin-arm64-1.0.0.zip");
    
                IWebDriver driver = new RemoteWebDriver(
                    new Uri("https://key:secret@hub.testingbot.com/wd/hub"),
                    options
                );
    
                // Generate two random numbers between 0 and 9
                Random random = new Random();
                int num1 = random.Next(0, 10);
                int num2 = random.Next(0, 10);
    
                IWebElement firstNumber = driver.FindElement(By.Id($"btn-{num1}"));
                IWebElement secondNumber = driver.FindElement(By.Id($"btn-{num2}"));
                IWebElement plus = driver.FindElement(By.Id("btn-plus"));
                IWebElement equal = driver.FindElement(By.Id("btn-equal"));
    
                // Perform operations
                firstNumber.Click();
                plus.Click();
                secondNumber.Click();
                equal.Click();
    
                // Get the result
                IWebElement resultElement = driver.FindElement(By.Id("calc-display"));
                string resultText = resultElement.Text;
    
                // Verify the result
                if ((num1 + num2) != int.Parse(resultText))
                {
                    throw new Exception("Test failed");
                }
    
                // Quit the driver
                driver.Quit();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error during test execution: {ex.Message}");
            }
        }
    }

The example above will run the TestingBot Demo Electron app on a remote macOS machine. You can also choose to run the demo app on a remote Windows machine inside TestingBot's grid, please see the capabilities below.

    options = Selenium::WebDriver::Options.chrome
    options.browser_name = "electron"
    options.platform_name = "WIN10"
    options.browser_version = "42"
    options.add_option("tb:binary_location", "testingbot-electron-demo-app.exe")
    options.add_option("tb:app", "https://github.com/testingbot/testingbot-electron-demo-app/releases/download/v1.0.0/testingbot-electron-demo-app-win32-x64-1.0.0.zip")

## Configuring Electron tests

To configure your Electron test with TestingBot, you need to supply 3 capabilities:

- [app capability](https://testingbot.com#capability-app)
- [binary\_location capability](https://testingbot.com#capability-binary)
- Electron version capability

Please use the `version` or `browserVersion` capability to indicate to TestingBot which version of Electron was used to create the final app that you are testing.

TestingBot needs to know which version was used, so that we can map it to the Chromium version that is being used for that particular Electron version. For example, if you created your Electron app with Electron 42, you would need to provide `browserVersion: 42` as a capability.

## Electron Test Results

Test results for each Electron test will be available in the TestingBot member dashboard. For each Electron test, you will get access to a video recording, generated log files and additional meta-data.

These results are also available through the TestingBot [REST-API](https://testingbot.com/support/api) or by using one of the [TestingBot CI/CD plugins](https://testingbot.com/support/integrations/ci-cd).

### Looking for more help?

Have questions or need more information? Reach out via email or Slack.

[Email us](https://testingbot.com/contact/new)[Slack Join our Slack](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
