折腾:
【未解决】自动抓包工具适配iOS:isPublicAccountFocusOrIntoPage_iOS报错AttributeError NavigableString object has no attribute attrs
期间,结果xcodebuild的test manager报错:
020-04-28 10:45:56.139949+0800 WebDriverAgentRunner-Runner[3546:2305976] [xpc.exceptions] <NSXPCConnection: 0x282540240> connection to service on pid 336 named com.apple.testmanagerd: Exception caught during decoding of reply to message '_XCT_fetchSnapshotForElement:attributes:parameters:reply:', dropping incoming message and calling failure block. Ignored Exception: Exception while decoding argument 0 (#1 of invocation): <NSInvocation: 0x280e3f240> return value: {v} void target: {@?} 0x0 (block) argument 1: {@} 0x0 argument 2: {@} 0x0 Exception: decodeObjectForKey: too many nested collections ( 0 CoreFoundation 0x00000001ba056a5c 7519E999-1053-3367-B9D5-8844F6D3BDC6 + 1227356 1 libobjc.A.dylib 0x00000001b9d7dfa4 objc_exception_throw + 56 2 Foundation 0x00000001ba5422d0 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339536 3 Foundation 0x00000001ba54264c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340428 4 Foundation 0x00000001ba31be3c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 85564 5 XCTAutomationSupport 0x0000000105032104 -[XCAccessibilityElement initWithCoder:] + 120 ... 303 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339<…> 2020-04-28 10:47:01.083465+0800 WebDriverAgentRunner-Runner[3546:2301775] Error Domain=com.apple.dt.XCTest.XCTFuture Code=1000 "Timed out while fetching snapshot from testmanagerd.." UserInfo={NSLocalizedDescription=Timed out while fetching snapshot from testmanagerd..} t = 1481.90s Find the Window
此处app页面卡死在:
优理氏的
在线客服
抓包log也是:
[200428 10:45:54][DevicesMethods.py 1143] start get iOS page source [200428 10:46:54][DevicesMethods.py 1173] get_page_source failed
暂停运行,看看是否可以获取到截图:
self.getCurScreenshot()
结果:不可用
先网上搜搜
_XCT_fetchSnapshotForElement:attributes:parameters:reply dropping incoming message and calling failure block
NSXPCConnection connection to service on pid named com.apple.testmanagerd
Exception caught during decoding of reply to message
NSXPCConnection Exception caught during decoding of reply to message
记录一个完整部分的log
2020-04-28 10:49:13.283259+0800 WebDriverAgentRunner-Runner[3546:2307345] [xpc.exceptions] <NSXPCConnection: 0x282540240> connection to service on pid 336 named com.apple.testmanagerd: Exception caught during decoding of reply to message '_XCT_fetchSnapshotForElement:attributes:parameters:reply:', dropping incoming message and calling failure block. Ignored Exception: Exception while decoding argument 0 (#1 of invocation): <NSInvocation: 0x280fa4900> return value: {v} void target: {@?} 0x0 (block) argument 1: {@} 0x0 argument 2: {@} 0x0 Exception: decodeObjectForKey: too many nested collections ( 0 CoreFoundation 0x00000001ba056a5c 7519E999-1053-3367-B9D5-8844F6D3BDC6 + 1227356 1 libobjc.A.dylib 0x00000001b9d7dfa4 objc_exception_throw + 56 2 Foundation 0x00000001ba5422d0 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339536 3 Foundation 0x00000001ba54264c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340428 4 Foundation 0x00000001ba31be3c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 85564 5 XCTAutomationSupport 0x0000000105032104 -[XCAccessibilityElement initWithCoder:] + 120 6 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339400 7 Foundation 0x00000001ba54264c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340428 8 Foundation 0x00000001ba31ba7c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 84604 9 XCTAutomationSupport 0x000000010501bedc -[XCElementSnapshot initWithCoder:] + 120 10 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339400 11 Foundation 0x00000001ba5426a4 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340516 12 Foundation 0x00000001ba559e9c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2436764 13 Foundation 0x00000001ba328024 7B1733B1-74C9-3A33-8A58-853B0A029826 + 135204 14 Foundation 0x00000001ba331470 7B1733B1-74C9-3A33-8A58-853B0A029826 + 173168 15 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339400 16 Foundation 0x00000001ba54264c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340428 17 Foundation 0x00000001ba31be3c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 85564 18 XCTAutomationSupport 0x000000010501c738 -[XCElementSnapshot initWithCoder:] + 2260 19 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339400 20 Foundation 0x00000001ba5426a4 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340516 21 Foundation 0x00000001ba559e9c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2436764 22 Foundation 0x00000001ba328024 7B1733B1-74C9-3A33-8A58-853B0A029826 + 135204 23 Foundation 0x00000001ba331470 7B1733B1-74C9-3A33-8A58-853B0A029826 + 173168 24 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339400 25 Foundation 0x00000001ba54264c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340428 26 Foundation 0x00000001ba31be3c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 85564
后面就都是:XCTAutomationSupport的循环错误了。
且也写了:too many nested collections
都是递归调用,估计是
算了,不行的话,就重新去单独调试该页面,重新启动 test manager 看看能否获取源码
先不重启,看看单独调试,现在能否获取页面源码
先中断AppCrawler
结果连不上server
卡死了。
只能重启test manager了
^C *** If you believe this error represents a bug, please attach the result bundle at /Users/xxx/Library/Developer/Xcode/DerivedData/WebDriverAgent-doxykunuiuxsdzeisbkcuadwxyab/Logs/Test/Test-WebDriverAgentRunner-2020.04.28_10-22-14-+0800.xcresult 2020-04-28 11:09:47.973 xcodebuild[15548:269747] [MT] IDETestOperationsObserverDebug: 2853.124 elapsed -- Testing started completed. 2020-04-28 11:09:47.974 xcodebuild[15548:269747] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start 2020-04-28 11:09:47.974 xcodebuild[15548:269747] [MT] IDETestOperationsObserverDebug: 2853.124 sec, +2853.124 sec -- end Test session results, code coverage, and logs: /Users/xxx/Library/Developer/Xcode/DerivedData/WebDriverAgent-doxykunuiuxsdzeisbkcuadwxyab/Logs/Test/Test-WebDriverAgentRunner-2020.04.28_10-22-14-+0800.xcresult ** TEST INTERRUPTED **
重启
不过先去看看
/Users/xxx/Library/Developer/Xcode/DerivedData/WebDriverAgent-doxykunuiuxsdzeisbkcuadwxyab/Logs/Test/
发现很多相关文件:
而此处的:
Test-WebDriverAgentRunner-2020.04.28_10-22-14-+0800.xcresult
下面有多个文件:
但是很多data和refs是二进制
其他的文本数据,也看不太懂
Test-WebDriverAgentRunner-2020.04.28_10-22-14-+0800.xcresult/Data/data.0~Yq7akzTVTQA5s8UBEqEk9mDmjbCAlFydBk7vjupJWl82wQg1enVBZMempJtpLqr0Urmeafd60jCM6dCpViXD2w==
[{"name":"WebDriverAgentRunner-4F56AE7F-6409-497E-8605-2A23B90A8C99","type":2},{"name":"scheduling.log","type":1}]
Test-WebDriverAgentRunner-2020.04.28_10-22-14-+0800.xcresult/Data/data.0~Ubpyf8_n3_5i1BcXm4acO_AhbCrHkSz3V7ZDp0XOlJbsV_hGWf7-So5rkN7gzCQ6V7Zw3PC9g2LNSfLeSx-9FA==
Failed to capture app hierarchy
这个能看懂,获取页面层级 即页面源码失败
找不到有价值的东西。
Impossible to update itunes – eehelp.com
看起来都是和RPC XPC远程 跨进程调用 关于类的编码和解码 而报错的
NSSecureCoding
initWithCoder
注意到上面是:
[XCElementSnapshot initWithCoder:] + 120
即:XCElementSnapshot的initWithCoder
出错的
NSXPCConnection XCElementSnapshot initWithCoder
算了,找不到解决办法,只能重启test manger:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=`idevice_id -l | head -n1`" test
重新测试看看
结果又报错了:
2020-04-28 11:25:53.623351+0800 WebDriverAgentRunner-Runner[3571:2315632] Using singleton test manager 2020-04-28 11:26:16.630520+0800 WebDriverAgentRunner-Runner[3571:2315449] Getting the most recent active application (out of 1 total items) 2020-04-28 11:26:16.766198+0800 WebDriverAgentRunner-Runner[3571:2315449] Getting the most recent active application (out of 1 total items) t = 23.17s Requesting snapshot of accessibility hierarchy for app with pid 3560 2020-04-28 11:26:16.859412+0800 WebDriverAgentRunner-Runner[3571:2315633] [xpc.exceptions] < : 0x280c8b3c0> connection to service on pid 336 named com.apple.testmanagerd: Exception caught during decoding of reply to message '_XCT_fetchSnapshotForElement:attributes:parameters:reply:', dropping incoming message and calling failure block. Ignored Exception: Exception while decoding argument 0 (#1 of invocation): <NSInvocation: 0x282643f40> return value: {v} void target: {@?} 0x0 (block) argument 1: {@} 0x0 argument 2: {@} 0x0 Exception: decodeObjectForKey: too many nested collections ( 0 CoreFoundation 0x00000001ba056a5c 7519E999-1053-3367-B9D5-8844F6D3BDC6 + 1227356 1 libobjc.A.dylib 0x00000001b9d7dfa4 objc_exception_throw + 56 2 Foundation 0x00000001ba5422d0 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339536 3 Foundation 0x00000001ba54264c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340428 4 Foundation 0x00000001ba31be3c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 85564 5 XCTAutomationSupport 0x00000001020fe104 -[XCAccessibilityElement initWithCoder:] + 120 6 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339400 7 Foundation 0x00000001ba54264c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340428 8 Foundation 0x00000001ba31ba7c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 84604 9 XCTAutomationSupport 0x00000001020e7edc -[XCElementSnapshot initWithCoder:] + 120 10 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339400 11 Foundation 0x00000001ba5426a4 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340516 12 Foundation 0x00000001ba559e9c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2436764 13 Foundation 0x00000001ba328024 7B1733B1-74C9-3A33-8A58-853B0A029826 + 135204 14 Foundation 0x00000001ba331470 7B1733B1-74C9-3A33-8A58-853B0A029826 + 173168 15 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339400 16 Foundation 0x00000001ba54264c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2340428 17 Foundation 0x00000001ba31be3c 7B1733B1-74C9-3A33-8A58-853B0A029826 + 85564 18 XCTAutomationSupport 0x00000001020e8738 -[XCElementSnapshot initWithCoder:] + 2260
看来:
只能是想办法,删除旧的WebDriverAgent, 重新用XCode编译一遍后,再去试试?
问题依旧:
此处在线客服页面,无法获取页面源码
一旦去获取页面源码,就会导致:test manager崩溃
后续都无法正常使用了。。。
那目前看来,或许只能是:
不获取源码,而只是去查找元素?
如果能找到 在线客服 就跳过 不去获取源码?
此处log也显示无法获取xml
0200428 11:54:05 __init__.py:164 DEBUG Shell: curl -X GET -d '' 'http://localhost:8100/source?format=xml' 20200428 11:54:05 connectionpool.py:221 DEBUG Starting new HTTP connection (1): localhost:8100 20200428 11:56:16 connectionpool.py:428 DEBUG http://localhost:8100 "GET /source?format=xml HTTP/1.1" 500 199 20200428 11:56:16 __init__.py:178 DEBUG Return (130628ms): { "value" : { "error" : "unknown error", "message" : "Cannot get 'xml' source of the current application", "traceback" : "" }, "sessionId" : "32878C21-6FDD-4EE7-A975-6A5B9FAB7FB4" }
另外 XCode的test manager最后还报错:
303 Foundation 0x00000001ba542248 7B1733B1-74C9-3A33-8A58-853B0A029826 + 2339<…> 2020-04-28 11:56:16.550594+0800 WebDriverAgentRunner-Runner[3579:2321202] Failed to invoke libxml2>xmlTextWriterStartElement for the tag value '(null)'. Error code: -1 2020-04-28 11:56:16.551098+0800 WebDriverAgentRunner-Runner[3579:2321202] Failed to generate XML presentation of a screen element Entity: line 2: parser error : Extra content at the end of the document ^ error : xmlTextWriterWriteDocCallback : XML error 5 !
那去获取json试试
同样发现:test manager卡死,需要重新安装才行
这就难办了。毕竟没办法获取当前页面xml源码,写代码检测,都难
突然想到,还是XCode去实时调试看看:
【规避解决】XCode实时调试NSXPCConnection的_XCT_fetchSnapshotForElement:attributes:parameters:reply错误
【总结】
最后是把
会崩溃出错的 iOS 13.3.1的iPhone8P
换成:iOS 11.4.1的iPhone6P
就正常能获取到上述页面的源码,而不会崩溃了。
转载请注明:在路上 » 【规避解决】WebDriverAgent获取页面源码报错:xpc.exceptions NSXPCConnection com.apple.testmanagerd _XCT_fetchSnapshotForElement