Skip to content

fix(appium): missing await on some steps of runOnIOS and runOnAndroid #4018

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

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions lib/helper/Appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ class Appium extends Webdriver {
async runOnIOS(caps, fn) {
if (this.platform !== 'ios') return;
recorder.session.start('iOS-only actions');
this._runWithCaps(caps, fn);
recorder.add('restore from iOS session', () => recorder.session.restore());
await this._runWithCaps(caps, fn);
await recorder.add('restore from iOS session', () => recorder.session.restore());
return recorder.promise();
}

Expand Down Expand Up @@ -465,8 +465,8 @@ class Appium extends Webdriver {
async runOnAndroid(caps, fn) {
if (this.platform !== 'android') return;
recorder.session.start('Android-only actions');
this._runWithCaps(caps, fn);
recorder.add('restore from Android session', () => recorder.session.restore());
await this._runWithCaps(caps, fn);
await recorder.add('restore from Android session', () => recorder.session.restore());
return recorder.promise();
}

Expand Down
12 changes: 6 additions & 6 deletions test/helper/AppiumV2_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,23 +716,23 @@ describe('Appium', function () {
await app.see('Welcome to register a new User');
});

it('should execute only on Android @quick', () => {
it('should execute only on Android @quick', async () => {
let platform = null;
app.runOnIOS(() => {
await app.runOnIOS(() => {
platform = 'ios';
});
app.runOnAndroid(() => {
await app.runOnAndroid(() => {
platform = 'android';
});
app.runOnAndroid({ platformVersion: '7.0' }, () => {
await app.runOnAndroid({ platformVersion: '7.0' }, () => {
platform = 'android7';
});

assert.equal('android', platform);
});

it('should execute only on Android >= 5.0 @quick', () => {
app.runOnAndroid(caps => caps.platformVersion >= 5, () => {});
it('should execute only on Android >= 5.0 @quick', async () => {
await app.runOnAndroid(caps => caps.platformVersion >= 5, () => {});
});

it('should execute only in Web', () => {
Expand Down