WebDriverAgent icon indicating copy to clipboard operation
WebDriverAgent copied to clipboard

With usePreinstalledWda on, WDA is launched with wdaLocalPort instead of wdaRemotePort

Open pohsoon opened this issue 3 months ago • 1 comments

usePreinstalledWDA + prebuiltWdaPath uses wdaLocalPort for device USE_PORT instead of wdaRemotePort

Problem

With usePreinstalledWDA set to true and prebuiltWdaPath set to a WDA app bundle folder path, the WDA's device listen port (USE_PORT) is unexpectedly set from wdaLocalPort. All other launch paths and XCUITest port forwarding use wdaRemotePort for the device port.

If wdaLocalPort ≠ wdaRemotePort, WDA listens on the wrong port and forwarding fails (e.g. Connection was refused to port 8100).

Verified on master @ 0387506 (2026-08-06).

Expected

Per xcuitest capabilities docs:

  • wdaLocalPort → host proxy / forwarder bind port
  • wdaRemotePort → device WDA HTTP listen port

Bug

// lib/wda-strategies.ts:320 — wrong
USE_PORT: ctx.wdaLocalPort || WDA_AGENT_PORT,

ctx.wdaRemotePort is passed to launchPreinstalled() but ignored for USE_PORT.

Other paths (correct)

Path USE_PORT from
xcodebuild wdaRemotePort (lib/xcodebuild.ts:446)
xctestrun wdaRemotePort (lib/utils/xctestrun.ts:71)
usePreinstalledWDA wdaLocalPort ❌

WDA reads USE_PORT as its bind port (FBConfiguration.m:134-137).

XCUITest driver forwards host url.port → wdaRemotePort (appium-xcuitest-driver/lib/commands/wda/startup.ts:110-111).

Repro

{
 "appium:usePreinstalledWDA": true,
 "appium:wdaLocalPort": 9100,
 "appium:wdaRemotePort": 8100
}
  • Expected: WDA on 8100, forward host:9100 → device:8100
  • Actual: WDA on 9100, forward targets 8100 → refused

Hidden when only wdaLocalPort is set (wdaRemotePort defaults to same value).

Prior art

#915 (v8.7.5) fixed this for xcodebuild; preinstalled path was missed.

Unit test in test/unit/webdriveragent.spec.ts asserts USE_PORT: 9100 when wdaLocalPort: 9100 — no test for differing ports.

Fix

- USE_PORT: ctx.wdaLocalPort || WDA_AGENT_PORT,
+ USE_PORT: ctx.wdaRemotePort || WDA_AGENT_PORT,

Add regression test: wdaLocalPort: 9100, wdaRemotePort: 8100 → USE_PORT: 8100.

pohsoon avatar Aug 11 '26 03:08 pohsoon

:tada: This issue has been resolved in version 16.1.7 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Aug 11 '26 16:08 github-actions[bot]