Electron app with protractor end-to-end testing

安稳与你 提交于 2019-12-03 13:33:43

问题


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.


回答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)




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

  // ...
}


来源:https://stackoverflow.com/questions/31329361/electron-app-with-protractor-end-to-end-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!