Fix unreachable exception in USBClient initialization and add wda_bundle_id parameter
The RuntimeError in USBClient.__init__ was unreachable due to a return statement preceding the raise, making WDA readiness validation ineffective.
Changes
USBClient.init (line 1765-1776)
# Before: exception never thrown
if self.is_ready():
return
raise RuntimeError("WDA is not ready after waiting for 20 seconds")
# After: proper timeout with error handling and future-ready API
def __init__(self, udid: str = "", port: int = 8100, wda_bundle_id: str = None):
...
if not self.wait_ready(timeout=20, noprint=True):
raise RuntimeError("WDA is not ready after waiting for 20 seconds")
- Replaced single
is_ready()check withwait_ready(timeout=20)to match error message semantics - Fixed control flow to make exception reachable when WDA fails to initialize
- Added
wda_bundle_idparameter to support future functionality (currently unused but available for extension)
Selector._fix_xcui_type (line 1350)
- Added raw string prefix to regex replacement:
r'/XCUIElementType\g<1>'to eliminateSyntaxWarning
API Changes
The USBClient constructor now accepts an optional wda_bundle_id parameter:
driver = wda.USBClient(udid=self.udid, port=8100, wda_bundle_id=self.wda_bundle_id)
This parameter is reserved for future use and maintains backward compatibility with existing code.
- Fixes openatx/facebook-wda#171
Original prompt
This section details on the original issue you should resolve
<issue_title>新版本代码漏检以及建议</issue_title> <issue_description>这个异常看起来不会抛出
请问移除了tidevice会计划引入go-ios或pymobiledevice3吗?还是说启动wda由用户自行解决?</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes openatx/facebook-wda#171
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
try to support
driver=wda.UsBClient(udid=self.udid,port=8100,wda_bundle_id=self.wda_bundle_id)
even through wda_bundle_id is not using now. @copilot
try to support
driver=wda.UsBClient(udid=self.udid,port=8100,wda_bundle_id=self.wda_bundle_id)
...
Added wda_bundle_id parameter to USBClient.__init__() with signature: USBClient(udid: str = "", port: int = 8100, wda_bundle_id: str = None). The parameter is ready for future use. (8e82397)