Skip to content

Can Selenium Be Used for Electron Testing?

Anna Thorsen

Anna Thorsen

Selenium is one of the most widely used test automation tools. However, automating tests in Electron using Selenium is challenging. It is very limited in capabilities, leaving Electron-based applications exposed to risk>

In this post, you’ll read about why businesses use Electron, why Selenium is limiting when automating applications built on Electron, and the solutions that enable teams to automate Electron testing.

Why businesses use Electron

Businesses use Electron because of its ability to easily “host” desktop versions of their web-based applications.

Why is this?

When a business service, like Microsoft Teams, relies on connections to hardware (e.g. microphones, cameras, etc.), they struggle with providing a good user experience.

For example, every time a user accesses Teams on the web, they have to configure their settings to allow connections to these peripherals. If this is not done, any hacker could wreak havoc on their machine.

Electron solves this problem.

It’s an app that you can install on your machine, and use to develop and deploy native desktop-based applications using web technologies.

Think of it like a television. The screen (surface) shows us the web version of the desktop application that we interact with. The tv box (what happens “under the hood”) is Electron and it connects the web version to all the hardware/peripherals without constantly asking for user permission.

how-electron-works-v1

Why Selenium won’t work for Electron

The huge benefit of Electron is that any new feature, update, or change published on the browser-based application will also show on the Electron-based desktop version running on your machine. But this doesn’t make testing any easier, especially when it is done with Selenium.

Related reading: The Challenge of Electron Testing

Selenium doesn’t work well for Electron because you have to figure out and make the automation navigate what is happening on the surface, and what is happening under the hood.

This is a very cumbersome process, and it isn’t possible with Selenium. You would have to build the capability to do this with code yourself, which is far from ideal.

To be able to automate testing of unique applications built on Election, you need to adopt other automation tools. So what capabilities does your automation tool need when testing Electron applications, and how will it benefit your business?

In this next post on Electron testing, we cover the pros and cons of automation frameworks and commercial tools. We also mention the resource and maintenance expectations for heavy-code, low-code, and codeless selenium solutions.

If you want to learn more about finding the right agile test automation solution, get our whitepaper on discovering the right tool for agile development.

New call-to-action