AirtestProject / Airtest

UI Automation Framework for Games and Apps
http://airtest.netease.com/
Apache License 2.0
8.3k stars 1.31k forks source link

airtest ios连接的api: connect_device无法连接多台ios #1206

Open csushiye opened 7 months ago

csushiye commented 7 months ago

现在airtest脚本api:connect_device连接ios设备时只能给定127.0.0.1:8100,无法连接多台ios设备?通过tidevice -u uuid wdaproxy启动多台ios设备的wda后,每个设备wda的端口映射到macOs机器不同端口,connect_device参数给定127.0.0.1:不同的端口,实际都是连接的127.0.0.1:8100的设备,无法连接多台设备

ztwo commented 7 months ago

iOS:///http://127.0.0.1:{port}/?udid={device_id} 加上设备ID试试

csushiye commented 7 months ago

iOS:///http://127.0.0.1:{port}/?udid={device_id} 加上设备ID试试

应该还是有问题的,看IOS的建立连接逻辑是默认使用8100端口,如果port采用非8100端口,调用start_recording录屏时还是会报如下错误: During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/urllib3/connectionpool.py", line 715, in urlopen httplib_response = self._make_request( File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/urllib3/connectionpool.py", line 416, in _make_request conn.request(method, url, **httplib_request_kw) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1285, in request self._send_request(method, url, body, headers, encode_chunked) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1331, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1280, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1040, in _send_output self.send(msg) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 980, in send self.connect() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/requests_usbmux.py", line 54, in connect conn = _device.create_inner_connection(int(port)) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/usbmux.py", line 238, in create_inner_connection raise MuxConnectError( wda.exceptions.MuxConnectError: device port:8100 is not ready

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/requests/adapters.py", line 486, in send resp = conn.urlopen( File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/urllib3/connectionpool.py", line 799, in urlopen retries = retries.increment( File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/urllib3/util/retry.py", line 550, in increment raise six.reraise(type(error), error, _stacktrace) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/urllib3/packages/six.py", line 769, in reraise raise value.with_traceback(tb) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/urllib3/connectionpool.py", line 715, in urlopen httplib_response = self._make_request( File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/urllib3/connectionpool.py", line 416, in _make_request conn.request(method, url, **httplib_request_kw) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1285, in request self._send_request(method, url, body, headers, encode_chunked) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1331, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1280, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1040, in _send_output self.send(msg) File "/opt/homebrew/Cellar/python@3.9/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 980, in send self.connect() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/requests_usbmux.py", line 54, in connect conn = _device.create_inner_connection(int(port)) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/usbmux.py", line 238, in create_inner_connection raise MuxConnectError( urllib3.exceptions.ProtocolError: ('Connection aborted.', MuxConnectError('device port:8100 is not ready'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/bigo/mat/uibrick/tests/ios_uibrick_unittest.py", line 54, in test_tap_debugtool airtest_device.start_recording() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 51, in wrapper return func(self, *args, kwargs) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 1304, in start_recording self.recorder = ScreenRecorder( File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/aircv/screen_recorder.py", line 113, in init self.tmp_frame = self.get_frame_func() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 1297, in get_frame data = self.get_frame_from_stream() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 51, in wrapper return func(self, *args, *kwargs) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 659, in get_frame_from_stream return self.mjpegcap.get_frame_from_stream() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/utils/snippet.py", line 127, in ready_func return func(inst, args, kwargs) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/mjpeg_cap.py", line 103, in get_frame_from_stream return self.get_blank_screen() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/mjpeg_cap.py", line 145, in get_blank_screen display_info = self.ori_function() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 336, in self.mjpegcap = MJpegcap(self.instruct_helper, ori_function=lambda: self.display_info, File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 544, in display_info self._display_info() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 551, in _display_info window_size = self.window_size() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 51, in wrapper return func(self, *args, *kwargs) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/airtest/core/ios/ios.py", line 507, in window_size return self.driver.window_size() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/init.py", line 1031, in window_size size = self._unsafe_window_size() File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/init.py", line 1055, in _unsafe_window_size value = self._session_http.get('/window/size').value File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/utils.py", line 47, in _inner return fn(args, kwargs) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/init.py", line 459, in _fetch response = httpdo(url, method, data, timeout) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/init.py", line 130, in httpdo return _unsafe_httpdo(url, method, data, timeout) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/wda/init.py", line 157, in _unsafe_httpdo response = request_session.request(method, File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, send_kwargs) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "/Users/bigo/.local/share/virtualenvs/uibrick-iYraLzmP/lib/python3.9/site-packages/requests/adapters.py", line 501, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', MuxConnectError('device port:8100 is not ready'))

企业微信截图_17133472671069

rere332 commented 7 months ago

请问你们连接ios 机器的时候, 有没有遇到这个报错 currently only supports port forwarding for locally connected iOS devices

Screenshot 2024-04-26 at 12 09 27
csushiye commented 7 months ago

请问你们连接ios 机器的时候, 有没有遇到这个报错 currently only supports port forwarding for locally connected iOS devices

Screenshot 2024-04-26 at 12 09 27

你是不是当时还连了其他设备,而其他设备没有把wda正常启动,然后是会报这个错的;这个堆栈的中调用函数逻辑是会有个遍历当前连接的所有设备,然后调用wda的包和每个设备进行连接,获取设备的udid和你目的的udid比较,如果和某个设备建立连接失败,就会报这个错误