I can't get webDriverAgentUrl capability to work for wifi address

I have many devices connected to my mac, and I try to run programs on them.

For a device, I see it can have two ip.

  • The ip from USB, I usually get such ip by connecting the iphone to the mac. so something like 169.254.xxx.xxx, usually I get this through arp -a
  • The ip from wifi, for example 192.168.1.xxx

I don’t want to reinstall and run webdriveragent each time, but rather have webdriveragent run continuously. I start the webdriveragent with

xcodebuild test-without-building \
  -xctestrun ./DerivedData/${iphone_id}/Build/Products/WebDriverAgentRunner_iphoneos18.2-arm64.xctestrun \
  -destination "id=${iphone_id}"

And also set the webDriverAgentUrl. For example, for usb ip, this always works.

"appium:webDriverAgentUrl": "http://169.254.xxx.xxx:8100"

However, with wifi ip, it does not work.

"appium:webDriverAgentUrl": "http://192.168.1.xxx:8100"

I run curl http://192.168.1.xxx:8100/status, and it could not connect. but ping 192.168.1.xxx works.

USB is actually not that stable (sometimes requires one to unplug and plug it in again), so I would like to use the wifi IP. How would I go about this?

Currently this scenario would not be not possible unless the new connection protocol gets implemented by GitHub - appium/appium-ios-device: Tools for interacting with iOS devices

thanks, I need to find an alternative method then.

I realize I don’t really need it to support wifi ip.

The main issue originally is the USB addresses are not stable, sometimes after device upgrade or reset, the original USB ip no longer works, and I have no way of accessing that device. I want to use WIFI ip because it is fixed, so I can always connect to the device.

Now I realize I can just use iproxy to map the device port to a distinct local port, say 810x, and then just do

"appium:webDriverAgentUrl": "http://localhost:810x"

I solved it as:

  • one per day reboot devices by command:
// in loop rebooting all phones
idevicediagnostics -u " + deviceCapabilities.get("udid") + " restart
  • before tests to get connected devices use:
// wait up to 5 sec to get connected devices
ios-deploy -c -t 5 -W
// and reading all records with `Found`