1
私はMacでjavaコードを使用してappiumサーバーを起動するために次のスニペットを使用しました。appiumサーバーをプログラムで起動する方法は?
public void startAppium() throws ExecuteException, IOException, InterruptedException {
CommandLine command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node"); command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js", false);
command.addArgument("--address", false);
command.addArgument("127.0.0.1");
command.addArgument("--port", false);
command.addArgument("4723");
command.addArgument("--no-reset", false);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
Thread.sleep(50000);
System.out.println("Appium Server starting");
}
@BeforeTestの中で上記のメソッドを呼び出しています。 @BeforeMethodの中で、私は望みの能力について言及しています。サーバが起動し、それは同様に必要な能力を取っているが、それは誤りで、次のログを示している。
e[36minfoe[39m: e[37m-->e[39m e[37mPOSTe[39m e[37m/wd/hub/sessione[39m e[90m{"desiredCapabilities":{"app":"/Users/aaaa/dd/qd.apk","appPackage":"com.xxx.xxx","appActivity":"com.xxx.xxx.MainActivity","newCommandTimeout":"1200","platformName":"Android","deviceName":"Android Device"}}e[39m
e[36minfoe[39m: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.8.0_73)
e[36minfoe[39m: [debug] Using local app from desired caps: /Users/aaaa/dd/qd.apk
e[36minfoe[39m: [debug] Creating new appium session 6a2245bd-d1ac-443c-bf5f-c6e2c2f64e22
e[36minfoe[39m: Starting android appium
e[36minfoe[39m: [debug] Getting Java version
e[36minfoe[39m: [debug] Cleaning up android objects
e[36minfoe[39m: [debug] Cleaning up appium session
e[31merrore[39m: Failed to start an Appium session, err was: Error: 'java -version' failed. Error: Command failed: /bin/sh -c java -version /bin/sh: java: command not found
e[36minfoe[39m: [debug] Error: 'java -version' failed. Error: Command failed: /bin/sh -c java -version
/bin/sh: java: command not found
私は、プロジェクトの環境変数にJAVA_HOMEを設定することで、試してみましたが、それは役に立ちません。
誰でもこの提案をお願いします。事前に感謝します。