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

fix: launchApp regression #1540

Merged
merged 4 commits into from
Mar 31, 2023
Merged
Changes from 1 commit
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
27 changes: 8 additions & 19 deletions lib/commands/general.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _ from 'lodash';
import {retryInterval} from 'asyncbox';
import {errors} from 'appium/driver';
import {util} from 'appium/support';
import moment from 'moment-timezone';
Expand Down Expand Up @@ -202,24 +201,14 @@ const commands = {
* @this {XCUITestDriver}
*/
async launchApp() {
const APP_LAUNCH_TIMEOUT = 20 * 1000;

this.logEvent('appLaunchAttempted');
await this.opts.device.launchApp(this.opts.bundleId);

let checkStatus = async () => {
let response = await this.proxyCommand('/status', 'GET');
let currentApp = response.currentApp.bundleID;
if (currentApp !== this.opts.bundleId) {
throw new Error(`${this.opts.bundleId} not in foreground. ${currentApp} is in foreground`);
}
};

this.log.info(`Waiting for '${this.opts.bundleId}' to be in foreground`);
let retries = parseInt(APP_LAUNCH_TIMEOUT / 200, 10);
await retryInterval(retries, 200, checkStatus);
this.log.info(`${this.opts.bundleId} is in foreground`);
this.logEvent('appLaunched');
const appName = this.opts.app || this.opts.bundleId;
try {
await this.start();
this.log.info(`Successfully launched the '${appName}' app.`);
KazuCocoa marked this conversation as resolved.
Show resolved Hide resolved
} catch (err) {
this.log.warn(`Something went wrong while launching the '${appName}' app.`);
throw err;
}
},
/**
* @this {XCUITestDriver}
Expand Down