* Helper method to safely call isDisplayed() on mobile elements. * Handles the case where webdriverio tries to use execute/sync which isn't supported in Appium. * @private
(element)
| 418 | * @private |
| 419 | */ |
| 420 | async _isDisplayedSafe(element) { |
| 421 | if (this.isWeb) { |
| 422 | // For web contexts, use the normal isDisplayed |
| 423 | return element.isDisplayed() |
| 424 | } |
| 425 | |
| 426 | try { |
| 427 | return await element.isDisplayed() |
| 428 | } catch (err) { |
| 429 | // If isDisplayed fails due to execute/sync not being supported in native mobile contexts, |
| 430 | // fall back to assuming the element is displayed (since we found it) |
| 431 | if (err.message && err.message.includes('Method is not implemented')) { |
| 432 | return true |
| 433 | } |
| 434 | throw err |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | /** |
| 439 | * Execute code only on iOS |
no test coverage detected