简体   繁体   中英

process failed with exit code 1

I'm trying to run "nightmare" script, for screen shots using the following code: "usr.dir" contain the path until the "\\src\\...."

String root = System.getProperty("usr.dir");
String screenshotJS = "node " + root + "\\src\\main\\resources\\screenshot.js";
try {

  File tempFile = File.createTempFile(root, ".png");

  Process p = Runtime.getRuntime().exec(screenshotJS + " " + url + " " + tempFile.toString());

  p.waitFor();

  int exitCode = p.exitValue();
  if (exitCode != 0) {
    System.out.println("Error Execute when exitCode=1");
  }else{
    System.out.println("Fine Execute when exitCode=0");
    }

  BufferedImage bufferedImage = new BufferedImage(
          500, 500, BufferedImage.TYPE_INT_RGB );
  File outputfile = new File(tempFile.getName());
  ImageIO.write(bufferedImage, "png", outputfile);
  return tempFile.getName();

The nightmare script:

    const nightmare = require('nightmare')();
    nightmare
   .goto(process.argv[2])
   .viewport(1152, 864)
   .screenshot(process.argv[3] || 'screenshot.png')
   .end(() => {});

The return value of the process is 1. What I'm doing wrong ? can someone please assist me with this case?

Thanks,

Ido

npm i nightmare奔跑后,问题解决了

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM