0

Our application is developed using electron framework. it is a standalone application. I have seen that spectron is the framework which is used to automate electron application. but i am not sure whether it is applicable for desktop application. Please confirm the same.

I have installed nodejs and spectron. I have written a code launch application as mention in the following site https://electron.atom.io/spectron/

File Name : 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)
})

i have tried to run the script using command

node First.js

But i am getting error saying that

C:\spectronprgs>node First.js

Error: Cannot find module 'spectron'

Please let me know whether I am going towards right path how to launch .exe file using spectron framework how to run the script

1 Answers1

2

run the following from the command line.

npm install --save-dev spectron

Then see if you can find the module. You never mentioned in your post how you installed spectron.

user2263572
  • 4,619
  • 5
  • 30
  • 49
  • I have downloaded all the dependencies specified in the github documentation. Now I am able to launch the application.But I am not able to find the methods specified there. For Example Please find the below link https://github.com/electron/spectron/issues/143 elementIdText is a method of client object. But this method is not available when download all the dependencies and try to code. – user8659826 Oct 25 '17 at 08:38
  • I have downloaded all the dependencies specified in the github documentation. Now I am able to launch the application.But I am not able to find the methods specified there. For Example Please find the below link https://github.com/electron/spectron/issues/143 elementIdText is a method of client object. But this method is not available when download all the dependencies and try to code. can any one help me – user8659826 Oct 25 '17 at 08:59