有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法运行程序AUTOIT脚本名称CreateProcess error=216

我正在使用Selenium自动化我的网站。我正在尝试使用AUTOIT脚本将图像上载到我的网站

为此,我首先单击上载按钮。然后,我使用AUTOIT脚本在windows对话框中填充图像路径

这是我的自动IT脚本:

WinWait("Open","",10)
ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1",$CmdLine[1])
ControlClick("Open","","Button1")

当我编译并运行这段代码时,只要传递一个参数,它就可以正常工作。这在以前的代码中也可以正常工作。但它突然停止工作,给了我一个错误:

Cannot run program "Path to EXE": CreateProcess error=216, This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher.

这是我的Selenium代码。我在Runtime.getRuntime()行中遇到错误

headShotButton.click();
URL resource = Main.class.getResource("/UploadControlScript.exe");
String absolutePath = "";
try {
    absolutePath = Paths.get(resource.toURI()).toString();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
    Assert.fail("unable to get the Upload control script used (AUTOIT)" + e.getMessage().toString());
}
Process process = Runtime.getRuntime().exec(absolutePath + " " + uploadObj.ImageUploadPath);
InputStream is = process.getInputStream();
int retCode = 0;
while (retCode != -1) {
        retCode = is.read();
}

尝试过的解决方案:

  1. 我已经将java编译器设置为JDK1.8(最新版本)
  2. 我已经添加了环境变量“JAVA_HOME”,并将其目录设置为jdk 1.8 latest文件夹

共 (0) 个答案