Skip to content

Commit fb0d87e

Browse files
DavertMikclaude
andcommitted
fix(appium): resolve "Unsupported helper type: unknown" in fillField
Appium extends WebDriver but WebElement._detectHelperType only checked constructor.name === 'WebDriver', so Appium helpers fell through to 'unknown'. fillRichEditor (added in #5527) wraps elements in WebElement and calls evaluate(), which then threw on every fillField/appendField call from Appium. - WebElement now walks the prototype chain so any subclass of WebDriver/Playwright/Puppeteer is detected correctly. - WebDriver.fillField skips fillRichEditor when isWeb === false, since rich-editor detection needs a DOM that doesn't exist in Appium native. - Appium constructor: appiumV2 defaulted via `|| true` (always truthy); the v1-deprecation banner then fired on every default-config user. Fixed both: explicit `appiumV2: false` is now honored, and the banner only prints when the user opts into v1. - Added regression tests for prototype-chain detection. - Enabled the Android Appium workflow on pull_request to 4.x so the fix can be verified end-to-end via Sauce Labs from the PR. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6c7e718 commit fb0d87e

5 files changed

Lines changed: 31 additions & 9 deletions

File tree

.github/workflows/appium_Android.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches:
66
- 4.x
77
- appium-esm-migration
8+
pull_request:
9+
branches:
10+
- 4.x
811

912
concurrency:
1013
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}

lib/element/WebElement.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ class WebElement {
1515
_detectHelperType(helper) {
1616
if (!helper) return 'unknown'
1717

18-
const className = helper.constructor.name
19-
if (className === 'Playwright') return 'playwright'
20-
if (className === 'WebDriver') return 'webdriver'
21-
if (className === 'Puppeteer') return 'puppeteer'
18+
let ctor = helper.constructor
19+
while (ctor && ctor.name) {
20+
if (ctor.name === 'Playwright') return 'playwright'
21+
if (ctor.name === 'WebDriver') return 'webdriver'
22+
if (ctor.name === 'Puppeteer') return 'puppeteer'
23+
ctor = Object.getPrototypeOf(ctor)
24+
}
2225

2326
return 'unknown'
2427
}

lib/helper/Appium.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ class Appium extends Webdriver {
179179
super(config)
180180

181181
this.isRunning = false
182-
this.appiumV2 = config.appiumV2 || true
182+
this.appiumV2 = config.appiumV2 !== false
183183
this.axios = axios.create()
184184

185-
if (!config.appiumV2) {
186-
console.log('The Appium core team does not maintain Appium 1.x anymore since the 1st of January 2022. Appium 2.x is used by default.')
185+
if (this.appiumV2 === false) {
186+
console.log('Appium 1.x is no longer maintained by the Appium team (since 2022-01-01).')
187187
console.log('More info: https://bit.ly/appium-v2-migration')
188-
console.log('This Appium 1.x support will be removed in next major release.')
188+
console.log('Appium 1.x support will be removed in the next major CodeceptJS release.')
189189
}
190190
}
191191

lib/helper/WebDriver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ class WebDriver extends Helper {
12641264
const elem = selectElement(res, field, this)
12651265
highlightActiveElement.call(this, elem)
12661266

1267-
if (await fillRichEditor(this, elem, value)) {
1267+
if (this.isWeb !== false && await fillRichEditor(this, elem, value)) {
12681268
return
12691269
}
12701270

test/unit/WebElement_test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ describe('WebElement', () => {
3636

3737
expect(webElement.helperType).to.equal('unknown')
3838
})
39+
40+
it('should detect Appium as webdriver via prototype chain', () => {
41+
class WebDriver {}
42+
class Appium extends WebDriver {}
43+
const webElement = new WebElement({}, new Appium())
44+
45+
expect(webElement.helperType).to.equal('webdriver')
46+
})
47+
48+
it('should detect subclasses of Playwright as playwright', () => {
49+
class Playwright {}
50+
class CustomPlaywright extends Playwright {}
51+
const webElement = new WebElement({}, new CustomPlaywright())
52+
53+
expect(webElement.helperType).to.equal('playwright')
54+
})
3955
})
4056

4157
describe('getText()', () => {

0 commit comments

Comments
 (0)