0

I am looking to start some service using the command line tool from within the nightwatch. Searched a lot over the internet but found nothing related.

Appreciate if someone can provide an example to execute system commands.

Wamique
  • 59
  • 2
  • 5
  • can you add a bit more information on what you are trying to achieve. Also please share the code that you tried. – Alapan Das May 11 '21 at 14:34
  • I would like to run system commands. Tried below code: ` test('start minikube', client => { const cmd = "ls -lrt" client.execute(function (){ const execSync = require('child_process').execSync execSync(cmd) }, []) }) ` Getting below error: Error while running .executeScript() protocol action: An error occurred while executing user supplied JavaScript. – javascript error: execSync is not defined – Wamique May 11 '21 at 17:47

1 Answers1

1

You need to run the code using NodeJS code and definitely not NightwatchJS. I have noticed that you are trying to execute it using client.excute(). Please note that this runs in the browser and not in the system. You should explicitly run your system code using NodeJS and outside Nightwatchjs commands.

Raju
  • 2,299
  • 2
  • 16
  • 19