Skip to content

Commit

Permalink
feat: launch WDA via devicectl object (#870)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: calls launch app process command with devicectl via this.device.devicectl
  • Loading branch information
KazuCocoa authored Mar 25, 2024
1 parent d7dc6c6 commit 090b815
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions lib/webdriveragent.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,36 +307,11 @@ class WebDriverAgent {
* @return {Promise<void>}
*/
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.
Expand All @@ -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.`
);
}
}
Expand Down

0 comments on commit 090b815

Please sign in to comment.