← Front page
Search

Testing Electron Applications With Robot Framework's Selenium2Library

[EDIT: 2.46 seems to be the latest ChromeDriver which works this way.]

[EDIT2: No need to use ChromeDriver 2.46. Updated to article to match current situation.]

Since Electron contains Chromium and ChromeDriver can talk to Chromium and Selenium is just webdriver implementation, SeleniumLibrary can be used to test Electron apps.

First you need to download ChromeDriver version which matches what your application uses. If you do not know that, just download the newest and run the test specified below and your Robot Framework output will complain something like this:

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 97
Current browser version is 83.0.4103.122 with binary path path/to/electron/app

Then download ChromeDriver to match the version mentioned in the error message.

Then create a python file, let's say, vars.py with following content:

binary_location = {"goog:chromeOptions": {"binary": "path/to/electron/application.exe"}}

And finally create your Robot Framework test suite, like this:

*** Settings ***
Library    SeleniumLibrary    run_on_failure=Log Source
Variables    vars.py

*** Test Cases ***
Foo
    Create Webdriver    Chrome    desired_capabilities=${binary_location}
    Wait Until Page Contains Element    css=.workspace
    [Teardown]    Close All Browsers

Happy testing!