2
votes

I have an Electron app packaged as an app.asar file. It runs fine when opened with Electron, and I need to find a way to run tests on it through Robot Framework.

The problem is that while I can start the Electron app through Robot, I cannot find a way to pass it the app.asar file. And both the app and Electron are located in entirely different locations.

Based on the only very succinct source I could find mentioning both Electron and Robot Framework, I made the following:

vars.py :

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

ElectronTest.txt

*** Settings ***
Library           Selenium2Library
Library           OperatingSystem
Variables         vars.py

*** Variables ***
${Delay}          1s
${executor}       http://localhost:9515

*** Test Cases ***
Foo
    Set Selenium Speed    ${Delay}
    Create Webdriver    Remote    desired_capabilities=${binary_location}    command_executor=${executor}
    Wait Until Page Contains Element    css=.workspace
    [Teardown]    Close All Browsers

*** Keywords ***

Set Environment Variable
    webdriver.chrome.driver    ./chromedriver.exe

This starts Electron but gives me the following error:

The app provided is not a valid electron app, please read the docs on how to write one: https://github.com/atom/electron/tree/master/docs

Error: Cannot find module 'C:\path\to\ElectronTest:data'

Which makes sense, considering I didn't actually pass the app, even though I don't know why it is looking for an app in the Robot Framework folder

I also tried replacing the executor with the path to my app, as such:

${executor}      file://C:/path/to/my/app/dist/app.asar

In that case, I get the following error from Robot Framework:

URLError: urlopen error [Error 3] The system cannot find the path specified: u'path\to\my\app\dist\app.asar\session'

No idea why it would try to reach "app.asar\session".

I'm guessing I'm missing a parameter somewhere, but no matter how much I search and try, I cannot find any way to solve this.

Is there any way to pass a .asar file to Electron through Robot Framework?

1
i think chromeOptions should be goog:chromeOptions. Were you ever able to figure this problem out?chasethesunnn

1 Answers

0
votes

The instructions you linked to assume that you've packaged your electron app into a .exe. It's not clear if you did that first step or not, but the error message implies that you did not ("The app provided is not a valid electron app").

If you didn't, you might want to read [Application Distribution][1] in the electron docs. When you are done, you will have created a custom .exe that includes your asar file and whatever other files. It is the path to this .exe and not the electron.exe that you downloaded that you must start with robot.