Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron app with protractor end-to-end testing

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.

like image 406
cha55son Avatar asked Jul 09 '15 22:07

cha55son


People also ask

Is Protractor deprecated?

As Protractor approaches the end of its life, find out what this means for you and your testing team, and how we can help! As the development team of Protractor ceases to maintain the open-source automated testing tool, we see the end of an era of sorts.

Can we automate non-Angular application using Protractor?

Protractor is a test framework for web applications. Even though its primary use is for performing end-to-end testing in Angular and AngularJS applications, you can also use it for regular, non-Angular websites.

What is Protractor E2E?

Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, using Selenium. We can say in other words that Protractor is a tool that helps us to test Angular Apps using Selenium.


2 Answers

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)

like image 106
alecxe Avatar answered Sep 27 '22 23:09

alecxe


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!
     }
   },

  // ...
}
like image 28
BladeBarringer Avatar answered Sep 28 '22 01:09

BladeBarringer