2017-09-23 89 views
0

我們的應用程序是使用電子框架開發的。它是一個獨立的應用程序。我已經看到,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框架 如何運行腳本

回答

1

運行在命令行下啓動.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

相關問題