()
| 358 | } |
| 359 | |
| 360 | export async function goBack() { |
| 361 | if (device.getPlatform() !== 'ios') { |
| 362 | await device.pressBack(); |
| 363 | return; |
| 364 | } |
| 365 | |
| 366 | const callsite = captureCallsite(goBack); |
| 367 | |
| 368 | // Try each back/close affordance in order; retry the full set up to 10 times. |
| 369 | const candidates = [by.id('BackButton'), by.id('NavigationCloseButton'), by.label('Back'), by.text('Close')]; |
| 370 | |
| 371 | for (let attempt = 0; attempt < 10; attempt++) { |
| 372 | for (const matcher of candidates) { |
| 373 | try { |
| 374 | await element(matcher).atIndex(0).tap(); |
| 375 | return; |
| 376 | } catch (_) { |
| 377 | /* try next */ |
| 378 | } |
| 379 | } |
| 380 | await sleep(500); |
| 381 | } |
| 382 | |
| 383 | rethrowWithCallsite(new Error('goBack: no back/close affordance tappable after 10 attempts.'), callsite); |
| 384 | } |
| 385 | |
| 386 | export async function typeTextIntoAlertInput(text) { |
| 387 | if (device.getPlatform() === 'android') { |
no test coverage detected