testsigma
left-mobile-bg

Electron Testing | What it is and How to Perform?

November 19, 2024
Ganesh Hegde
right-mobile-bg
electron testing
image

Start automating your tests 10X Faster in Simple English with Testsigma

Try for free

Building a desktop application requires a lot of effort as there are different types of platforms, such as Windows, Mac, Linux, etc. The Electron application is the modern way to create desktop applications using the Chromium engine and NodeJS. Just like any desktop application electron testing needs to be carried out for Electron applications.

What is an Electron Application?

The Electron applications are a type of desktop applications that are created using the open-source ElectronJS framework. Electron application uses the potential of a web application to create a desktop application. The front-end components are rendered using the powerful Chromium engine and uses the NodeJS in the backend. The Electron application can use CSS, HTML, Javascript, and other web application libraries.

What is Electron Testing?

Electron Testing is the process of testing the Electron applications to ensure functionality across the platform. The Electron applications are built with ElectronJS. This utilizes the capability of Chromium and NodeJS along with web-based components such as HTML, CSS, JS, etc. Many modern application applications use the Electron. Some of the examples are MS Teams, Postman, Atom, VS Code, etc. Electron testing can be carried out using the popular automation framework like Selenium or Playwright.

Examples of Electron Applications

There are many applications written in Electron. As a user, you might be using them unknowingly. Below are some of the list of popular Electron applications

  • Postman
  • Teams by Microsoft
  • Visual Studio Code by Microsoft
  • Atom
  • WebTorrent
  • WhatsApp Desktop

How to Test Electron Applications?

Electron applications use web components, but they don’t render on a browser. The Electron application launches its own window on the desktop, which makes the Electron application complicated to test. However, thankfully, there are a few tools that support Electron app testing. 

Manual Testing

The Electron application can be tested manually or through automation. The manual testing requires the following steps

  • Generate the Electron application build
  • Install the application on the desktop
  • Launch the Electron app
  • Test against the expected and actual behavior

Automation Testing

There are only a few automation tools that support Electron Testing. Some of the tools are Selenium, Playwright, and WebdriverIO. Since selenium is the most widely used open-source automation framework, we have taken an example of Selenium and the Electron driver to test the Electron application.

Steps to Test the Electron Applications

  1. Locate the electron app you want to test

The Electron applications are different from the web applications. The electron application contains the binaries. You need to prepare the electron app for testing.

  1. Install the electron-chromedriver

The Electron Chrome driver helps to interact with Electron apps.

  1. Install the selenium-webdriver

The Selenium webdriver functions just like any other application testing. 

Once you get all required components installed proceed to the next step.

  1. Create a driver instance

const webdriver = require(‘selenium-webdriver’)

const driver = new webdriver.Builder()

  // The “9515” is the port opened by ChromeDriver.

  .usingServer(‘http://localhost:9515’)

  .withCapabilities({

    ‘goog:chromeOptions’: {

      // Here is the path to your Electron binary.

      binary: ‘/Path-to-Your-App.app/Contents/MacOS/Electron’

    }

  })

  .forBrowser(‘chrome’)

  .build()

In the above code, we are creating the webdriver instance and then we are passing the electron driver port 9515. The binary path of your application is mentioned to launch the Electron App.

Code or No Code Automation for Electron?

There are different approaches to address the automation testing needs for Electron. As you can see from the above steps we have performed the automation testing by writing the code. There are different types of frameworks such as code, low code, and no code. Let’s understand one by one in detail.


Code-based automation

Code-based automation requires good technical knowledge. As you know automation is the simulation of user functionality. These simulations are performed by writing programming language/scripts such as Javascript, Java, C#, etc. The code-based automation tools are less expensive. Many code-based automation tools are open-sourced or free. But it requires time and effort to create a framework. Maintenance is a more challenging and time-consuming job. Depending on the feature or user interface changes, often requires rewriting or updating the automation scripts.

Low-code automation

Low code uses the combination of drag and drop and programming. This means coding will be minimal but still requires you to code. Unlike code-based automation tools, it doesn’t require in-depth technical knowledge but requires basic technical knowledge to perform day-to-day tasks. These are useful if the application is complex and when drag-and-drop support is not completely available.

No-Code automation

The no-code automation doesn’t require you to write any form of code. It is also known as codeless automation. All actions are performed using drag and drop or making some configuration changes. Tools like Testsigma offer no code automation to a great extent. One of the main advantages of no code automation is manual testers or people who have less technical knowledge can also contribute to the automation to make the process faster. Check here – Codeless Testing Tools

Why Codeless Automation can help with Electron Testing?

Codeless automation testing is becoming popular nowadays as it requires less technical or programming knowledge. There are some advantages in codeless automation let’s understand them.

Faster to automate

Using the code-less automation tool anyone can contribute to automation. So no need for dedicated resources for testing. The team can collaboratively contribute to the automation and achieve good coverage. The QA typically requires less time to debug and fix the scripts.

Speed up the release

As manual test cases can be easily converted to automation. The automation suite can be integrated into CI/CD pipelines which makes release faster.

Higher productivity

The Codeless automation tools come with easy-to-debug features. The productivity increases as QAs can only focus on test cases rather than core framework features. Furthermore, the learning curve is very low which makes the entire time will be dedicated to automation.

Challenges of Testing Electron Applications

Limited tools support

The Electron applications are supported by only limited automation tools. You need to choose between the available tools. The open-source tool may not be able to achieve complete testing coverage

Complex to set up the framework

The Electron applications are different from web application which runs on browser. To set up a robust framework requires a deep level of technical understanding.

Manual Testing is not feasible

As the application grows, it requires covering a large number of test cases. Completing the regression can take a couple of days to a week. So manual testing requires more effort and resources.

Cross Platform Testing

Usually, the electron applications are built to support the cross-platform. As the automation tool itself is limited we need to choose the best-fit tools. Testing the cross-platform compatibility makes it even more complex in Electron as it requires infrastructure setup.

Many organizations are now switching to Electron based desktop clients. The ElectronJS makes desktop applications more powerful and provides a rich user experience. However, electron application testing has its own challenges. Automating electron application is a major challenge as it requires a complex setup and tools availability is limited. The No-code automation tools can make the automation faster and more reliable.

Automate you End-to-End UI Tests for Web, Mobile, Desktop and APIs, 10x Faster with Testsigma

Try for free

Frequently Asked Questions (FAQ)

Can Selenium be used for Electron Testing?

Yes, Selenium can be used for Electron Testing. However, you need to install the Electron-specific drivers and configure them in order to test the Electron apps. Once the pre-requisite is completed and the initial launch of the Electron app is done, then the testing of electron applications is just like testing any web-based applications.

What Test framework should I Choose for Electron Test Automation and Why?

The test framework for Electron Test automation should be chosen based on your requirements. Both commercial and open-source automation frameworks are available in the market. WebdriverIO, Selenium, and Playwright are some of the open-source test automation tools for the Electron App. There are many no-code automation tools in the market. The no-code automation tool helps to increase the automation test coverage swiftly.

How do you Unit Test Electron Apps?

The Unit testing Electron requires the installation of one of the unit testing frameworks for example Jest. Once you install the unit testing library you can start by creating specs. Each spec contains the set of unit tests for the Electron app. In unit tests create assertions for actual and expected results.

Are PWA’s and Electron Apps are Same?

Progressive Web Applications (PWA) are web applications that operate in the browser and provides the native platform experience, On the other hand, Electron apps are just like desktop application they need to be installed. PWA’s doesn’t require any installation. Electron apps can interface with parts of your machine but PWA’s cannot do that. Some  examples of PWA’s are Starbucks, Twitter, BMW, etc.

Testsigma Author - Ganesh Hegde

Ganesh Hegde

Ganesh Hegde is having more than a decade of experience in Software Testing and Test Automation. Handled multiple roles like SDET, Test Architect, Test Lead, etc., and helped the organization with QA strategies, and streamline the QA process. He has expertise in many tools such as Selenium, Cypress, Protractor, Puppeteer, Cucumber, TestCafe, WebDriverIO, Playwright, JMeter, Postman, etc. He is passionate about exploring new tools and technologies, writing technical content, and blogging.

image

Start automating your tests 10X Faster in Simple English with Testsigma

Try for free
imageimage
Subscribe to get all our latest blogs, updates delivered directly to your inbox.

By submitting the form, you would be accepting the Privacy Policy.

RELATED BLOGS


Banking Application Testing | What it is & How to Perform?
TESTSIGMA ENGINEERING TEAM
AUTOMATION TESTING
Salesforce Automation Case Study: A Data-Driven Approach to Quality and Efficiency
TESTSIGMA ENGINEERING TEAM
AUTOMATION TESTING
Extensive Testing in Software Testing: What It Is & How to Perform It
SHREYA BOSE
AUTOMATION TESTING