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(appium): issue with async on runOnIos and runOnAndroid #4525

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

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

Expand All @@ -503,7 +503,7 @@ class Appium extends Webdriver {
}
/* eslint-enable */

async _runWithCaps(caps, fn) {
_runWithCaps(caps, fn) {
if (typeof caps === 'object') {
for (const key in caps) {
// skip if capabilities do not match
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 @@ -767,23 +767,23 @@ describe('Appium', function () {
await app.see('Welcome to register a new User')
})

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

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

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