如何自动化使用电子框架开发的桌面应用程序?

问题描述:

我们的应用程序是使用电子框架开发的。它是一个独立的应用程序。我已经看到,spectron是用于自动化电子应用的框架。但我不确定它是否适用于桌面应用程序。请确认一致。如何自动化使用电子框架开发的桌面应用程序?

我已经安装了nodejs和spectron。 我在下列网站写代码启动应用程序提 https://electron.atom.io/spectron/

文件名:First.js

var Application = require('spectron').Application 
var assert = require('assert') 

var app = new Application({ 
    path: 'C:\Users\ramass\AppData\Local\Programs\ngsolutions\ngsolutions.exe' 
}) 

app.start().then(function() { 
    // Check if the window is visible 
    return app.browserWindow.isVisible() 
}).then(function (isVisible) { 
    // Verify the window is visible 
    assert.equal(isVisible, true) 
}).then(function() { 
    // Get the window's title 
    return app.client.getTitle() 
}).then(function (title) { 
    // Verify the window's title 
    assert.equal(title, 'My App') 
}).then(function() { 
    // Stop the application 
    return app.stop() 
}).catch(function (error) { 
    // Log any failures 
    console.error('Test failed', error.message) 
}) 

我已经尝试使用命令

节点来运行该脚本首先.js

但是我收到错误说

C:\spectronprgs>node First.js 

Error: Cannot find module 'spectron' 

请让我知道我是否会朝着正确的道路 如何使用SPECTRON框架 如何运行脚本

运行在命令行下启动.exe文件。

npm install --save-dev spectron 

然后看看你是否能找到该模块。你从未在你的文章中提到你如何安装Spectron。

+0

我已经下载了github文档中指定的所有依赖关系。现在我可以启动应用程序了。但是我无法找到那里指定的方法。 例如请在下面找到链接 https://github.com/electron/spectron/issues/143 elementIdText是客户端对象的一种方法。 但是,下载所有依赖关系并尝试编码时,此方法不可用。 – user8659826

+0

我已经下载了github文档中指定的所有依赖关系。现在我可以启动应用程序了。但是我无法找到那里指定的方法。 例如请在下面找到链接 https://github.com/electron/spectron/issues/143 elementIdText是客户端对象的一种方法。 但是,下载所有依赖关系并尝试编码时,此方法不可用。 任何人都可以帮助我 – user8659826