DetoxRuntimeError:NSInvalidArgumentException + [UIWindowScene _keyWindowScene]:无法识别的选择器发送到类 0x12dd58
Posted
技术标签:
【中文标题】DetoxRuntimeError:NSInvalidArgumentException + [UIWindowScene _keyWindowScene]:无法识别的选择器发送到类 0x12dd58db0【英文标题】:DetoxRuntimeError: NSInvalidArgumentException +[UIWindowScene _keyWindowScene]: unrecognized selector sent to class 0x12dd58db0 【发布时间】:2021-11-20 09:11:55 【问题描述】:我已经安装了-g detox-cli
和detox --save-dev
(在项目根目录中),我可以构建应用程序,但是当我尝试运行它时,我总是收到这个错误。我检查了执行情况,并且正在显示带有文本的元素,但没有一个功能(toBeVisible、swipe、tap 等)成功。有谁知道会是什么?谢谢你。
尽管有文字描述,但它不是登录流程,它只是在板载屏幕上滑动。
Login flow › should be able to login
DetoxRuntimeError: The pending request #2 ("invoke") has been rejected due to the following error:
The app has crashed, see the details below:
Exception was thrown:
NSInvalidArgumentException
+[UIWindowScene _keyWindowScene]: unrecognized selector sent to class 0x12f6eedb0
(
0 CoreFoundation 0x000000010f2984a4 __exceptionPreprocess + 226
1 libobjc.A.dylib 0x000000010bf3fbe7 objc_exception_throw + 48
2 CoreFoundation 0x000000010f2a703a __CFExceptionProem + 0
3 CoreFoundation 0x000000010f29c9bc ___forwarding___ + 1433
4 CoreFoundation 0x000000010f29eae8 _CF_forwarding_prep_0 + 120
5 Detox 0x000000010bf9aa12 +[UIWindow(DetoxUtils) dtx_allKeyWindowSceneWindows] + 43
6 Detox 0x000000010bf9e7d1 +[UIView(DetoxMatchers) dtx_findViewsInKeySceneWindowsPassingPredicate:] + 56
7 Detox 0x000000010bfbb853 Detox.Element.(views in _14E24C92C1353FEA1FC68E698CB917EF).getter : Swift.Array<__C.NSObject> + 211
8 Detox 0x000000010bfbbba1 Detox.Element.(view in _14E24C92C1353FEA1FC68E698CB917EF).getter : __C.NSObject + 49
9 Detox 0x000000010bfbd4e7 Detox.Element.isVisible() throws -> Swift.Bool + 39
10 Detox 0x000000010bfb5005 Detox.ToBeVisibleExpectation._evaluate() -> () + 101
11 Detox 0x000000010bfb4ae5 closure #1 () -> () in Detox.Expectation.evaluate(completionHandler: (Swift.Optional<Swift.Error>) -> ()) -> () + 101
12 Detox 0x000000010bfafc8c reabstraction thunk helper from @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> () + 12
13 Detox 0x000000010bfad8ae reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () + 14
14 Detox 0x000000010bfa67fe +[DTXAssertionHandler try:error:] + 47
15 Detox 0x000000010bfb9e0c function signature specialization <Arg[1] = Dead, Arg[2] = Owned To Guaranteed, Arg[3] = Owned To Guaranteed> of function signature specialization <Arg[1] = [Closure Propagated : closure #1 (Swift.Optional<Swift.Dictionary<Swift.String, Any>>, Swift.Optional<Swift.Error>) -> () in closure #2 () -> () in Detox.DetoxManager.webSocket(_: Detox.WebSocket, didReceiveAction: Swift.String, params: Swift.Dictionary<Swift.String, Any>, messageId: __C.NSNumber) -> (), Argument Types : [Detox.DetoxManager__C.NSNumber]> of static Detox.InvocationManager.invoke(dictionaryRepresentation: Swift.Dictionary<Swift.String, Any>, completionHandler: (Swift.Optional<Swift.Dictionary<Swift.String, Any>>, Swift.Optional<Swift.Error>) -> ()) -> () + 1852
16 Detox 0x000000010bfd3f30 partial apply forwarder for closure #2 () -> () in Detox.DetoxManager.webSocket(_: Detox.WebSocket, didReceiveAction: Swift.String, params: Swift.Dictionary<Swift.String, Any>, messageId: __C.NSNumber) -> () + 64
17 Detox 0x000000010bfad8ae reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () + 14
18 DetoxSync 0x000000014367260d __36+[DTXSyncManager _tryIdleBlocksNow:]_block_invoke.132 + 184
19 libdispatch.dylib 0x0000000111724a82 _dispatch_call_block_and_release + 12
20 libdispatch.dylib 0x0000000111725c89 _dispatch_client_callout + 8
21 libdispatch.dylib 0x00000001117330a8 _dispatch_main_queue_callback_4CF + 1073
22 CoreFoundation 0x000000010f206125 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
23 CoreFoundation 0x000000010f200982 __CFRunLoopRun + 2772
24 CoreFoundation 0x000000010f1ff9cb CFRunLoopRunSpecific + 567
25 GraphicsServices 0x000000011546fcd3 GSEventRunModal + 139
26 UIKitCore 0x000000012e7ca457 -[UIApplication _run] + 928
27 DetoxSync 0x000000014366e2fd __detox_sync_UIApplication_run + 362
28 UIKitCore 0x000000012e7ceebf UIApplicationMain + 101
29 Lykon 0x00000001025825c0 main + 80
30 dyld 0x000000010ba4ae1e start_sim + 10
31 ??? 0x0000000000000001 0x0 + 1
)
11 |
12 | it('should be able to login', async () =>
> 13 | await expect(element(by.text('Want to become healthier?'))).toBeVisible();
| ^
14 | await element(by.text('Want to become healthier?')).swipe('left');
15 | await expect(element(by.text('Do like Ina, age 33'))).toBeVisible();
16 | await element(by.text('Do like Ina, age 33')).swipe('left');
at _callee3$ (firstTest.e2e.js:13:65)
at tryCatch (../node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:294:22)
at Generator.next (../node_modules/regenerator-runtime/runtime.js:119:21)
at tryCatch (../node_modules/regenerator-runtime/runtime.js:63:40)
at invoke (../node_modules/regenerator-runtime/runtime.js:155:20)
at ../node_modules/regenerator-runtime/runtime.js:190:11
detox[29661] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
➜ mobile-app git:(detox-config-new) ✗ detox test -c ios.sim.release
detox[29776] INFO: [test.js] DETOX_CONFIGURATION="ios.sim.release" DETOX_REPORT_SPECS=true DETOX_START_TIMESTAMP=1632822349209 DETOX_USE_CUSTOM_LOGGER=true jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
detox[29777] INFO: Login flow is assigned to 7575A670-2BDE-49EF-ADED-07AD59A1E43A iPhone 12
detox[29777] INFO: [AppleSimUtils.js] com.lykon.app launched. To watch simulator logs, run:
/usr/bin/xcrun simctl spawn 7575A670-2BDE-49EF-ADED-07AD59A1E43A log stream --level debug --style compact --predicate 'process == "Lykon"'
detox[29777] INFO: Login flow: should be able to login
detox[29777] INFO: Login flow: should be able to login [FAIL]
FAIL e2e/firstTest.e2e.js (21.925 s)
Login flow
✕ should be able to login (12693 ms)
● Login flow › should be able to login
DetoxRuntimeError: The pending request #2 ("invoke") has been rejected due to the following error:
The app has crashed, see the details below:
Exception was thrown:
NSInvalidArgumentException
+[UIWindowScene _keyWindowScene]: unrecognized selector sent to class 0x12dd58db0
(
0 CoreFoundation 0x000000010d9024a4 __exceptionPreprocess + 226
1 libobjc.A.dylib 0x000000010a5a9be7 objc_exception_throw + 48
2 CoreFoundation 0x000000010d91103a __CFExceptionProem + 0
3 CoreFoundation 0x000000010d9069bc ___forwarding___ + 1433
4 CoreFoundation 0x000000010d908ae8 _CF_forwarding_prep_0 + 120
5 Detox 0x000000010a604a12 +[UIWindow(DetoxUtils) dtx_allKeyWindowSceneWindows] + 43
6 Detox 0x000000010a6087d1 +[UIView(DetoxMatchers) dtx_findViewsInKeySceneWindowsPassingPredicate:] + 56
7 Detox 0x000000010a625853 Detox.Element.(views in _14E24C92C1353FEA1FC68E698CB917EF).getter : Swift.Array<__C.NSObject> + 211
8 Detox 0x000000010a625ba1 Detox.Element.(view in _14E24C92C1353FEA1FC68E698CB917EF).getter : __C.NSObject + 49
9 Detox 0x000000010a6185b0 Detox.SwipeAction.perform(on: Detox.Element) -> Swift.Optional<Swift.Dictionary<Swift.String, Any>> + 1392
10 Detox 0x000000010a618709 vtable thunk for Detox.Action.(perform in _04ABBB5C7C570871DB67625EF38728EC)(on: Detox.Element) -> Swift.Optional<Swift.Dictionary<Swift.String, Any>> dispatching to Detox.SwipeAction.perform(on: Detox.Element) -> Swift.Optional<Swift.Dictionary<Swift.String, Any>> + 9
11 Detox 0x000000010a6154ef Detox.Action.(perform in _04ABBB5C7C570871DB67625EF38728EC)(on: Detox.Element, completionHandler: (Swift.Optional<Swift.Dictionary<Swift.String, Any>>, Swift.Optional<Swift.Error>) -> ()) -> () + 31
12 Detox 0x000000010a61ad6a partial apply forwarder for closure #1 () -> () in Detox.Action.perform(completionHandler: (Swift.Optional<Swift.Dictionary<Swift.String, Any>>, Swift.Optional<Swift.Error>) -> ()) -> () + 42
13 Detox 0x000000010a61adb1 partial apply forwarder for reabstraction thunk helper from @callee_guaranteed () -> () to @escaping @callee_guaranteed () -> () + 17
14 Detox 0x000000010a6178ae reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () + 14
15 Detox 0x000000010a6107fe +[DTXAssertionHandler try:error:] + 47
16 Detox 0x000000010a6155fe Detox.Action.perform(completionHandler: (Swift.Optional<Swift.Dictionary<Swift.String, Any>>, Swift.Optional<Swift.Error>) -> ()) -> () + 238
17 Detox 0x000000010a623aa4 function signature specialization <Arg[1] = Dead, Arg[2] = Owned To Guaranteed, Arg[3] = Owned To Guaranteed> of function signature specialization <Arg[1] = [Closure Propagated : closure #1 (Swift.Optional<Swift.Dictionary<Swift.String, Any>>, Swift.Optional<Swift.Error>) -> () in closure #2 () -> () in Detox.DetoxManager.webSocket(_: Detox.WebSocket, didReceiveAction: Swift.String, params: Swift.Dictionary<Swift.String, Any>, messageId: __C.NSNumber) -> (), Argument Types : [Detox.DetoxManager__C.NSNumber]> of static Detox.InvocationManager.invoke(dictionaryRepresentation: Swift.Dictionary<Swift.String, Any>, completionHandler: (Swift.Optional<Swift.Dictionary<Swift.String, Any>>, Swift.Optional<Swift.Error>) -> ()) -> () + 980
18 Detox 0x000000010a63df30 partial apply forwarder for closure #2 () -> () in Detox.DetoxManager.webSocket(_: Detox.WebSocket, didReceiveAction: Swift.String, params: Swift.Dictionary<Swift.String, Any>, messageId: __C.NSNumber) -> () + 64
19 Detox 0x000000010a6178ae reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () + 14
20 DetoxSync 0x0000000141cdc60d __36+[DTXSyncManager _tryIdleBlocksNow:]_block_invoke.132 + 184
21 libdispatch.dylib 0x000000010fd8ea82 _dispatch_call_block_and_release + 12
22 libdispatch.dylib 0x000000010fd8fc89 _dispatch_client_callout + 8
23 libdispatch.dylib 0x000000010fd9d0a8 _dispatch_main_queue_callback_4CF + 1073
24 CoreFoundation 0x000000010d870125 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
25 CoreFoundation 0x000000010d86a982 __CFRunLoopRun + 2772
26 CoreFoundation 0x000000010d8699cb CFRunLoopRunSpecific + 567
27 GraphicsServices 0x0000000113ad9cd3 GSEventRunModal + 139
28 UIKitCore 0x000000012ce34457 -[UIApplication _run] + 928
29 DetoxSync 0x0000000141cd82fd __detox_sync_UIApplication_run + 362
30 UIKitCore 0x000000012ce38ebf UIApplicationMain + 101
31 Lykon 0x0000000100bec5c0 main + 80
32 dyld 0x000000010a0b4e1e start_sim + 10
33 ??? 0x0000000000000001 0x0 + 1
)
12 | it('should be able to login', async () =>
13 | //await expect(element(by.text('Want to become healthier?'))).toBeVisible();
> 14 | await element(by.text('Want to become healthier?')).swipe('left');
| ^
15 | await expect(element(by.text('Do like Ina, age 33'))).toBeVisible();
16 | await element(by.text('Do like Ina, age 33')).swipe('left');
17 | await expect(element(by.text('Stop the second guessing'))).toBeVisible();
at _callee3$ (firstTest.e2e.js:14:57)
at tryCatch (../node_modules/regenerator-runtime/runtime.js:63:40)
at Generator.invoke [as _invoke] (../node_modules/regenerator-runtime/runtime.js:294:22)
at Generator.next (../node_modules/regenerator-runtime/runtime.js:119:21)
at tryCatch (../node_modules/regenerator-runtime/runtime.js:63:40)
at invoke (../node_modules/regenerator-runtime/runtime.js:155:20)
at ../node_modules/regenerator-runtime/runtime.js:190:11
detox[29776] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e
这是我第一次在 Stack Overflow 上提问,我有点不知道应该提供什么信息。因此,如果您在需要更多信息时询问我,我将不胜感激。谢谢。
e2e/config.json:
"testEnvironment": "./environment",
"testRunner": "jest-circus/runner",
"testTimeout": 120000,
"testRegex": "\\.e2e\\.js$",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
e2e/environment.js
const
DetoxCircusEnvironment,
SpecReporter,
WorkerAssignReporter
= require('detox/runners/jest-circus');
class CustomDetoxEnvironment extends DetoxCircusEnvironment
constructor(config, context)
super(config, context);
// Can be safely removed, if you are content with the default value (=300000ms)
this.initTimeout = 300000;
// This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level.
// This is strictly optional.
this.registerListeners(
SpecReporter,
WorkerAssignReporter
);
module.exports = CustomDetoxEnvironment;
【问题讨论】:
【参考方案1】:detox 在本 PR 中讨论的 iOS 15 存在问题
https://github.com/wix/Detox/issues/2895
升级到 "detox": "^18.22.1"
为我修复了它
【讨论】:
谢谢!新版本解决了这个问题。 :)以上是关于DetoxRuntimeError:NSInvalidArgumentException + [UIWindowScene _keyWindowScene]:无法识别的选择器发送到类 0x12dd58的主要内容,如果未能解决你的问题,请参考以下文章
执行 Detox 测试命令后出现 DetoxRuntimeError
DetoxRuntimeError:NSInvalidArgumentException + [UIWindowScene _keyWindowScene]:无法识别的选择器发送到类 0x12dd58