在开始执行测试之前,我必须手动启动这个WinAppDriver.exe。
当我开始执行我的测试用例时,我想自动执行这个任务,它应该启动这个exe,在完成后它将关闭它。
我已经用下面的代码在Java中尝试过,但我没有成功:
Runtime runTime = Runtime.getRuntime();
String executablePath = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe";
Process process = runTime.exec(executablePath);注意:我需要使用‘以管理员身份运行’来运行它
发布于 2020-02-10 18:28:19
我建议使用java中的ProcessBuilder类,因为建议在Java5之后使用它来启动/创建进程。下面的代码将启动WinAppDriver.exe:
String command = "C:\Users\Administrator\WinAppDriver\WinAppDriverTool\WinAppDriver.exe";
ProcessBuilder builder = new ProcessBuilder(command).inheritIO();
startWinAppDriver = builder.start();希望这能有所帮助。
发布于 2020-02-19 14:26:14
这两个都为我工作,没有盯着eclipse作为管理员。
Runtime.getRuntime().exec("C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe");还有苏甘加德·辛格的回答。
String command = "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe";
ProcessBuilder builder = new ProcessBuilder(command).inheritIO();
builder.start();https://stackoverflow.com/questions/57731828
复制相似问题