From 090b815ae47e1ef0e0a9842fac6828346bc38fe6 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Mon, 25 Mar 2024 00:32:03 -0700 Subject: [PATCH] feat: launch WDA via devicectl object (#870) BREAKING CHANGE: calls launch app process command with devicectl via this.device.devicectl --- lib/webdriveragent.js | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/lib/webdriveragent.js b/lib/webdriveragent.js index 0d3a60188..11aec45f9 100644 --- a/lib/webdriveragent.js +++ b/lib/webdriveragent.js @@ -307,36 +307,11 @@ class WebDriverAgent { * @return {Promise} */ async _launchViaDevicectl(opts = {}) { - // FIXME: use appium-xcuitest-driver's Devicectl. Maybe it needs to be included in the `this.device`? - // - const {env} = opts; - let xcrunBinnaryPath; - try { - xcrunBinnaryPath = await fs.which('xcrun'); - } catch (e) { - throw new Error( - `xcrun has not been found in PATH. ` + - `Please make sure XCode development tools are installed`, - ); - } - - const cmd = [ - 'devicectl', - 'device', - 'process', - 'launch', - `--device`, this.device.udid, - '--terminate-existing' - ]; - if (!_.isEmpty(env)) { - cmd.push('--environment-variables', JSON.stringify(_.mapValues(env, (v) => _.toString(v)))); - }; - cmd.push(this.bundleIdForXctest); - - const {stdout} = await exec(xcrunBinnaryPath, cmd); - this.log.debug(`The output of devicectl command: ${stdout}`); + await this.device.devicectl.launchApp({ + bundleId: this.bundleIdForXctest, env, terminateExisting: true, + }); // Launching app via decictl does not wait for the app start. // We should wait for the app start by ourselves. @@ -350,7 +325,7 @@ class WebDriverAgent { throw new Error( `Failed to start the preinstalled WebDriverAgent in ${this.wdaLaunchTimeout} ms. ` + `The WebDriverAgent might not be properly built or the device might be locked. ` + - 'appium:wdaLaunchTimeout capability modifies the timeout.' + `The 'appium:wdaLaunchTimeout' capability modifies the timeout.` ); } }