bug: the visual service fails on Android Chrome through Appium 3 in the default WebDriver BiDi session (workaround: `wdio:enforceWebDriverClassic`)
Los mantenedores suelen responder en 1 día
@plum117 ya está trabajando en esto.
Desde el 9/10/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- android, typescript
- Área
- documentation, mobile-dev, testing-qa
Línea de trabajo
Start with the README and reproduce the failure using probe.mjs and test/visual.spec.js with MODE=bidi and MODE=classic. Inspect the visual service before hook and matcher or instance setup paths mentioned in the report. Done means Android Chrome users see the documented classic-session workaround and a clear warning instead of missing matcher errors.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Environment (please complete the following information):
- Node.js version: 24.20.0
- NPM version: 11.19.0
- Browser name and version: Chrome 133.0.6943.137 on an Android 16 emulator (Pixel 9 Pro, API 36)
- Platform name and version: macOS 27; Appium 3.8.0, UiAutomator2 driver 8.7.0 (appium-android-driver 14.2.0), Chromedriver 133.0.6943.141
- WebdriverIO version: 9.32.0 (also 10.0.0-alpha.163)
@wdio/visual-serviceversion: 10.1.0 (also thewdio0-v10-compliancebranch of #1213)
Config of WebdriverIO + @wdio/visual-service
capabilities.js
// MODE=bidi (default), classic or forward
const mode = process.env.MODE ?? 'bidi'
export const capabilities = {
platformName: 'Android',
browserName: 'Chrome',
'appium:automationName': 'UiAutomator2',
'appium:deviceName': process.env.DEVICE ?? 'emulator-5554',
'appium:newCommandTimeout': 240,
'appium:chromeOptions': { args: ['--no-first-run', '--disable-fre'] },
...(mode === 'classic' ? { 'wdio:enforceWebDriverClassic': true } : {}),
...(mode === 'forward' ? { 'appium:chromedriverForwardBiDi': true } : {}),
}
// The Android emulator reaches the host at 10.0.2.2
export const pageUrl = 'http://10.0.2.2:8765/mobile.html'
export { mode }
wdio.conf.js
import { capabilities, mode } from './capabilities.js'
export const config = {
runner: 'local',
hostname: '127.0.0.1',
port: 4723,
specs: ['./test/visual.spec.js'],
capabilities: [capabilities],
framework: 'mocha',
reporters: ['spec'],
services: [['visual', {
baselineFolder: `./.tmp/${mode}/baseline`,
screenshotPath: `./.tmp/${mode}/actual`,
}]],
logLevel: 'warn',
connectionRetryCount: 0,
mochaOpts: { timeout: 240000 },
}
Describe the bug
On Android Chrome through Appium 3, the visual service does not work in the default session. WebdriverIO opens a WebDriver BiDi session (browser.isBidi is true), but Appium does not support the browser BiDi commands in this session:
browser.url()fails:WebDriver Bidi command "browsingContext.navigate" failed with error: unknown method - Method has not yet been implemented- every
browser.execute()fails:WebDriver Bidi command "script.callFunction" failed with error: unknown command
The visual service runs all its client-side scripts with browser.execute(), so all the visual commands and matchers fail. With WebdriverIO 9 and the published 10.1.0, the service before hook fails (Error getting mobile screen size), the matchers are not added, and the user only sees expect(...).toMatchScreenSnapshot is not a function.
This is not a bug in the service code. The workaround is 'wdio:enforceWebDriverClassic': true in the capabilities: then all the tests pass. This repository uses it in its Android web configs since #417, but the README does not tell users.
WebdriverIO v10 requires Appium 3, so all the users who upgrade will get this problem on Android Chrome.
To Reproduce
A small repro: a WebdriverIO-only script (probe.mjs, no service) and a visual test (test/visual.spec.js). Steps:
- Start an Android emulator with Chrome (
emulator-5554). npm i -g appium@3,appium driver install uiautomator2, thenappium --port 4723 --allow-insecure "uiautomator2:chromedriver_autodownload".npm install, thennpm run page(serveswww/on port 8765; the emulator openshttp://10.0.2.2:8765/mobile.html).MODE=bidi npm run probe,MODE=bidi npm test, and the same withMODE=classicandMODE=forward. RunMODE=classic npm testtwo times: the first run saves the baselines.
package.json
{
"name": "wdio-appium3-android-bidi-repro",
"private": true,
"type": "module",
"scripts": {
"page": "python3 -m http.server 8765 --bind 127.0.0.1 --directory www",
"test": "wdio run wdio.conf.js",
"probe": "node probe.mjs"
},
"devDependencies": {
"@wdio/cli": "^9.32.0",
"@wdio/globals": "^9.31.3",
"@wdio/local-runner": "^9.32.0",
"@wdio/mocha-framework": "^9.32.0",
"@wdio/spec-reporter": "^9.32.0",
"@wdio/visual-service": "^10.1.0",
"webdriverio": "^9.32.0"
}
}
probe.mjs
// No visual service, no test runner: shows the WebdriverIO + Appium result only.
// Usage: MODE=bidi|classic|forward node probe.mjs
import { remote } from 'webdriverio'
import { capabilities, mode, pageUrl } from './capabilities.js'
const browser = await remote({ hostname: '127.0.0.1', port: 4723, logLevel: 'error', capabilities })
const run = async (name, fn) => {
try {
console.log(`${name}: OK ${JSON.stringify(await fn())?.slice(0, 60) ?? ''}`)
} catch (err) {
console.log(`${name}: ERROR ${err.message.split('\n')[0].slice(0, 150)}`)
}
}
try {
console.log(`mode ${mode}, isBidi: ${browser.isBidi}`)
await run('url()', async () => { await browser.url(pageUrl) })
await run('getUrl()', () => browser.getUrl())
await run('execute(() => document.title)', () => browser.execute(() => document.title))
await run('executeScript("return document.title", [])', () => browser.executeScript('return document.title', []))
} finally {
await browser.deleteSession()
}
test/visual.spec.js
import { browser, $, expect } from '@wdio/globals'
import { pageUrl } from '../capabilities.js'
describe('Android Chrome through Appium 3', () => {
it('opens the page', async () => {
console.log(`isBidi: ${browser.isBidi}`)
await browser.url(pageUrl)
await expect($('h1')).toHaveText('Visual test')
})
it('matches the screen', async () => {
await expect(browser).toMatchScreenSnapshot('screen')
})
it('matches an element', async () => {
await expect($('#target')).toMatchElementSnapshot('target')
})
})
www/mobile.html
<!doctype html>
<html>
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Mobile</title>
<style>
body { margin: 0; background: #fff; font-family: sans-serif; }
h1 { margin: 16px; font-size: 24px; color: #1b5e20; }
#target { margin: 16px; width: 200px; height: 100px; background: #388e3c; border: 4px solid #1b5e20; }
</style>
</head>
<body><h1>Visual test</h1><div id="target"></div></body>
</html>
Results (the same with WebdriverIO 9.32.0 and 10.0.0-alpha.163):
probe.mjs |
bidi (default) |
classic |
forward (appium:chromedriverForwardBiDi) |
|---|---|---|---|
isBidi |
true |
false |
true |
url() |
error: browsingContext.navigate … unknown method |
OK | error (same) |
execute(() => document.title) |
error: script.callFunction … unknown command |
"Mobile" |
error (same) |
executeScript('return document.title', []) |
OK | OK | OK |
npm test (visual service) |
3 of 3 fail | 3 of 3 pass | 3 of 3 fail |
Expected behavior
The visual service works on Android Chrome through Appium 3 in the default WebdriverIO session, or the docs tell users to use 'wdio:enforceWebDriverClassic': true, and the service gives a clear error.
Log
WebdriverIO 9.32.0 with the published 10.1.0, MODE=bidi:
WARN webdriverio:ShadowRootManager: Could not register shadow root preload script, shadow DOM will not be pierced in this session: WebDriver Bidi command "script.addPreloadScript" failed with error: unknown command
WARN @wdio/visual-service:@wdio/image-comparison-core:utils: Error getting mobile screen size:
Error: WebDriver Bidi command "script.callFunction" failed with error: unknown command - The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.
ERROR @wdio/utils:shim: Error: WebDriver Bidi command "script.callFunction" failed with error: unknown command - ...
1) Android Chrome through Appium 3 opens the page
WebDriver Bidi command "browsingContext.navigate" failed with error: unknown method - Method has not yet been implemented
2) Android Chrome through Appium 3 matches the screen
TypeError: expect(...).toMatchScreenSnapshot is not a function
3) Android Chrome through Appium 3 matches an element
TypeError: expect(...).toMatchElementSnapshot is not a function
Additional context
What I found about the cause (local tests on the emulator):
- WebdriverIO adds
webSocketUrl: trueto every session that has abrowserName, except Safari and'wdio:enforceWebDriverClassic': true(packages/webdriver/src/utils.ts). There is no exception for Appium. - Since Appium 2.5.0, the Appium server sends back its own BiDi URL when the client asks for one. UiAutomator2 does not forward the BiDi commands to Chromedriver by default, so
browsingContext.navigateandscript.callFunctionare not supported. An Appium maintainer said the same in webdriverio/webdriverio#14600. - With Appium 2.19.0 (UiAutomator2 4.2.9),
execute()also fails in this BiDi session, buturl()works: WebdriverIO uses the ClassicnavigateTo()whenbrowsingContext.navigatefails withunknown error(url.ts). Appium 3 sendsunknown method, so this fallback does not apply. Thus the visual service already fails with Appium 2.5+ in BiDi; Appium 3 also breaksurl(). - The option
'appium:chromedriverForwardBiDi': truemust forward BiDi to Chromedriver, but it has no effect in a browser session:startChromeSession()does not give the context name tosetupNewChromedriver(), socacheChromedriverCaps()returns before it saves the Chromedriver BiDi URL. (The webview path, line 292, gives it.) Chromedriver did return awebSocketUrl. - With that line patched locally, Appium forwards BiDi to Chromedriver and
url()works, butexecute()fails withno such frame - Context CHROMIUM not found: on mobile, the WebdriverIO context manager uses the Appium context name fromgetContext()as the current context (context.ts), and BiDi uses it as the browsing context ID. Afterbrowser.switchToWindow(await browser.getWindowHandle()),execute()works, and the visual service passes like in Classic. In this real BiDi session,execute('mobile: deviceInfo')fails withReferenceError: deviceInfo is not defined, andexecuteScript('mobile: deviceInfo', [])works (this confirms the change of #1220).
iOS Safari through Appium 3 (XCUITest) is not affected: WebdriverIO does not ask for BiDi for Safari.
Proposed work in this repository:
- README: for Android Chrome through Appium, set
'wdio:enforceWebDriverClassic': true(WebdriverIO v9 and v10). - When the matchers or the instance data cannot be set up because of this, give a clear warning with the workaround, not
toMatchScreenSnapshot is not a function.
The root causes are in WebdriverIO (points 1, 3, 5) and in appium-android-driver (point 4). Issues there are not opened yet.
Follow-up
The default BiDi session works only when all of the fixes below are done. A partial fix does not help: for example, with only the Appium fix, url() works but every execute() still fails.
This repository (closes this issue)
- README: for Android Chrome through Appium, set
'wdio:enforceWebDriverClassic': true(WebdriverIO v9 and v10). - A clear warning with this workaround when the service cannot set up in an Android BiDi session (not
toMatchScreenSnapshot is not a function).
appium/appium-android-driver (issue or PR to open)
-
startChromeSession()must give the context name tosetupNewChromedriver(), so thatappium:chromedriverForwardBiDiworks in a browser session (point 4). - Question: can the BiDi forward be the default for browser sessions?
webdriverio/webdriverio (issue to open)
- Mobile web BiDi: use the window handle, not the Appium context name (
CHROMIUM), as the browsing context ID (point 5). This bug is independent of Appium. - For Android Chrome through Appium: add
appium:chromedriverForwardBiDi: truewhen WebdriverIO asks for BiDi (after the Appium fix is released), or do not ask for BiDi (point 1). Keep BiDi when the user setswebSocketUrl: true, and do not change appium-geckodriver and appium-chromium-driver, because they support BiDi. - Optional: in
url(), also use the Classic fallback for the Appium 3 errorunknown method(point 3). - v10 migration guide, Appium section: Android Chrome needs
'wdio:enforceWebDriverClassic': trueuntil these fixes are released.
When the upstream fixes are released, we can test the default session again with the repro of this issue, and then update the README.
- Lenguaje dominante
- TypeScript
- Estrellas
- 156
- Forks
- 62
- Merge medio
- 2 h 2 min
- PR fusionados (30 d)
- 111
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de webdriverio/visual-testing
-
Proposal: a noise-tolerant compare mode with pixelmatch 8's windowSizePosiblemente ocupada @plum117 la tomó hace 2 días. Abiertoenhancement
webdriverio/visual-testing#1311 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
feat: support element screenshots of elements in a frame in WebDriver BiDi sessions (v9 `switchFrame()`, v10 `context.frame()`)Posiblemente ocupada @plum117 la tomó hace 2 días. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 50/100
webdriverio/visual-testing#1228 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Wait for Screenshot to MatchPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
webdriverio/visual-testing#690 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Using checkFullPageScreen method, capturing images with duplicate viewport and is not scrolling to the bottom of the pagePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertohelp wanted
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
webdriverio/visual-testing#125 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de webdriverio/visual-testing
Issues similares
-
Bayern feature:Application ready web
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
digitalfabrik/entitlementcard#3176 ·
Los mantenedores suelen responder en 7 días
-
[BUG] 运行位置的分支列表不自动刷新,外部新建的分支看不到Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
NanmiCoder/cc-haha#1533 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
🐛 Bug: Calendar work items cannot be opened on mobilePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100