Electron app with protractor end-to-end testing

All we need is an easy explanation of the problem, so here it is.

I’m currently working on an Electron app and I now want to integrate end-to-end testing with Protractor. I’ve reviewed the tutorials for Protractor and am now trying to adapt it to Electron. Since Electron runs as a standalone app, how do I do this?

It seems that Protractor stands-up a Selenium server that then tries to reach out to an available HTTP server and run tests such as click here, what url am I on, input this text, etc.

Therefore how would I go about allowing the selenium server access to the electron instance?

Anyway that’s my mindset on the situation, any help is appreciated and feel free to correct any of my assumptions.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Adapting the instructions documented at Using Selenium and WebDriver, here is what you need to put into your protractor config (using directConnect, as an example):

exports.config = {
    directConnect: true,

    capabilities: {
         browserName: "chrome",
         chromeOptions: {
             binary: '/Path-to-Your-App.app/Contents/MacOS/Atom'  // < IMPORTANT! 
         },  
    },

    // ...
}

(not tested)

Method 2

alecxe’s answer is mostly correct, but there’s one slight inaccuracy with it.

binary should be nested under chromeOptions like so:

exports.config = {
  directConnect: true,

  capabilities: {
     browserName: "chrome",
     chromeOptions: {
       binary: '/Path-to-Your-App.app/Contents/MacOS/Atom'  // < IMPORTANT!
     }
   },

  // ...
}

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply