Skip to content

Commit 801e06d

Browse files
DavertMikclaude
andcommitted
fix(appium): silence "Method is not implemented" log spam from isDisplayed
webdriverio v9 implements element.isDisplayed() by injecting a JS visibility check via POST /execute/sync. Appium's native context has no JS engine, so every call lands a "Method is not implemented" error in the wdio logger before the existing _isDisplayedSafe catch swallows it. Tests pass but logs are noisy with these false-positive errors during seeElement, click, grabTextFrom, grabAttributeFrom, etc. Override isDisplayed at the element level: short-circuit to true while in native context so the failing request is never issued. Matches the semantics _isDisplayedSafe already applies (treats "not implemented" as displayed since we found the element). In web/webview context, defer to the original implementation. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d30a101 commit 801e06d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

lib/helper/Appium.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,24 @@ class Appium extends Webdriver {
334334
}
335335
this.$$ = this.browser.$$.bind(this.browser)
336336

337+
// wdio v9 implements `element.isDisplayed()` for non-mobile contexts by
338+
// injecting a JS visibility check via POST /execute/sync. Appium's native
339+
// context cannot execute JS, so each call logs an ugly
340+
// "Method is not implemented" ERROR before the existing catch swallows it.
341+
// Short-circuit isDisplayed to `true` while in native context so the
342+
// request is never issued (matches existing _isDisplayedSafe semantics).
343+
const helper = this
344+
if (typeof this.browser.overwriteCommand === 'function') {
345+
this.browser.overwriteCommand(
346+
'isDisplayed',
347+
async function (origFn, ...args) {
348+
if (helper.isWeb) return origFn.call(this, ...args)
349+
return true
350+
},
351+
true,
352+
)
353+
}
354+
337355
this.isRunning = true
338356
if (this.options.timeouts && this.isWeb) {
339357
await this.defineTimeout(this.options.timeouts)

0 commit comments

Comments
 (0)