Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enable usePreinstalledWDA feature for simulators #866

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions lib/webdriveragent.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,19 @@ class WebDriverAgent {
xctestEnv.MJPEG_SERVER_PORT = this.mjpegServerPort;
}
this.log.info('Launching WebDriverAgent on the device without xcodebuild');
this.xctestApiClient = new Xctest(this.device.udid, this.bundleIdForXctest, null, {env: xctestEnv});

await this.xctestApiClient.start();
if (this.isRealDevice) {
this.xctestApiClient = new Xctest(this.device.udid, this.bundleIdForXctest, null, {env: xctestEnv});
await this.xctestApiClient.start();
} else {
await this.device.simctl.exec('launch', {
args: [
'--terminate-running-process',
this.device.udid,
this.bundleIdForXctest,
],
env: xctestEnv,
});
}

this.setupProxies(sessionId);
const status = await this.getStatus();
Expand Down Expand Up @@ -343,10 +353,7 @@ class WebDriverAgent {
}

if (this.usePreinstalledWDA) {
if (this.isRealDevice) {
return await this.launchWithPreinstalledWDA(sessionId);
}
throw new Error('usePreinstalledWDA is available only for a real device.');
return await this.launchWithPreinstalledWDA(sessionId);
}

this.log.info('Launching WebDriverAgent on the device');
Expand Down Expand Up @@ -460,10 +467,16 @@ class WebDriverAgent {

async quit () {
if (this.usePreinstalledWDA) {
this.log.info('Stopping the XCTest session');
if (this.xctestApiClient) {
this.log.info('Stopping the XCTest session');
this.xctestApiClient.stop();
this.xctestApiClient = null;
} else {
try {
await this.device.simctl.terminateApp(this.bundleIdForXctest);
} catch (e) {
this.log.warn(e.message);
}
}
} else if (!this.args.webDriverAgentUrl) {
this.log.info('Shutting down sub-processes');
Expand Down
Loading