进程失败,退出代码为1

问题描述 投票:0回答:1

我正在尝试运行“噩梦”脚本,使用以下代码进行屏幕截图:“usr.dir”包含直到“\ 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();

噩梦剧本:

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

这个过程的回报值是1.我做错了什么?有人可以帮助我这个案子吗?

谢谢,

走了

java nightmare
1个回答
0
投票

在我运行npm i nightmare后问题得到了解决

© www.soinside.com 2019 - 2024. All rights reserved.