DOMException 105仅在UI测试期间

时间:2017-01-05 06:10:52

标签: ios objective-c uiwebview xcode-ui-testing

我间歇性地得到一个未处理的DOMException 105.它只在运行我的UI测试时发生。

如果我发表评论loadHTMLString:baseURL使用UIWebView,则不再发生异常。

这使我的测试非常不可靠。关于如何解决这个问题的任何建议?

堆栈追踪:

2017-01-05 16:57:01.431 Allhomes[64245:4871703] *** Terminating app due to uncaught exception 'DOMException', reason: '*** DOMException 105'
*** First throw call stack:
(

0   CoreFoundation                      0x0000000110e4dd4b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x00000001104b721e objc_exception_throw + 48
2   CoreFoundation                      0x0000000110e4dc99 -[NSException raise] + 9
3   WebCore                             0x000000011785a542 _ZN7WebCore17raiseDOMExceptionEi + 370
4   WebCore                             0x000000011785a55e _ZN7WebCore23raiseTypeErrorExceptionEv + 14
5   WebCore                             0x00000001177e311e -[DOMRange setStart:offset:] + 158
6   UIKit                               0x000000010d92edab -[UIWebDocumentView text] + 292
7   UIKit                               0x000000010d6afcde _UIViewDescriptionAppendTextIfApplicable + 96
8   UIKit                               0x000000010d6afe91 -[UIView(UIDebugging) description] + 147
9   CoreFoundation                      0x0000000110e2374a -[NSArray descriptionWithLocale:indent:] + 362
10  Foundation                          0x000000010ff80a9e _NSDescriptionWithLocaleFunc + 66
11  CoreFoundation                      0x0000000110d8b7d7 __CFStringAppendFormatCore + 10983
12  CoreFoundation                      0x0000000110d88cc7 _CFStringCreateWithFormatAndArgumentsAux2 + 263
13  AccessibilityUtilities              0x000000012544e38f _AXStringForArgs + 333
14  UIAccessibility                     0x0000000125f29fe2 -[UIView(UIAccessibilityElementTraversal) _accessibilitySubviewsForGettingElementsWithOptions:] + 199
15  UIAccessibility                     0x0000000125f2ae3b -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 743
16  UIAccessibility                     0x0000000125f2aec6 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 882
17  UIAccessibility                     0x0000000125f2aec6 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 882
18  UIAccessibility                     0x0000000125f2aec6 -[UIView(UIAccessibilityElementTraversal) _addAccessibilityElementsAndOrderedContainersWithOptions:toCollection:] + 882
19  UIAccessibility                     0x0000000125f2b3e4 +[UIView(UIAccessibilityElementTraversal) _accessibilityElementsAndContainersDescendingFromViews:options:sorted:] + 472
20  UIAccessibility                     0x0000000125f2b599 -[UIView(UIAccessibilityElementTraversal) _accessibilityViewChildrenWithOptions:] + 186
21  UIKit                               0x0000000125db20ab -[UITableViewCellAccessibility _accessibilityRetrieveTableViewCellText] + 1551
22  UIKit                               0x0000000125db2ed1 -[UITableViewCellAccessibility _accessibilityChildren] + 1534
23  UIKit                               0x0000000125dac175 -[UITableViewCellAccessibility _accessibilityUserTestingChildren] + 82
24  UIKit                               0x0000000125dac0f7 -[UITableViewCellAccessibility _accessibilityUserTestingChildrenCount] + 24
25  UIKit                               0x0000000125dc0d24 -[UITableViewCellAccessibilityElement _accessibilityUserTestingChildrenCount] + 48
26  UIAccessibility                     0x0000000125f3890b -[NSObject(AXPrivCategory) accessibilityAttributeValue:] + 5720
27  UIAccessibility                     0x0000000125f53636 -[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotDescendantsWithAttributes:maxDepth:maxChildren:maxArrayCount:] + 1814
28  UIAccessibility                     0x0000000125f54f96 -[NSObject(UIAccessibilityAutomation) _accessibilityUserTestingSnapshotWithOptions:] + 557
29  UIAccessibility                     0x0000000125f36c0a -[NSObject(AXPrivCategory) accessibilityAttributeValue:forParameter:] + 7903
30  UIAccessibility                     0x0000000125f20856 _copyParameterizedAttributeValueCallback + 211
31  AXRuntime                           0x000000012558f532 _AXXMIGCopyParameterizedAttributeValue + 216
32  AXRuntime                           0x0000000125589f1c _XCopyParameterizedAttributeValue + 440
33  AXRuntime                           0x0000000125598de5 mshMIGPerform + 266
34  CoreFoundation                      0x0000000110ddf3d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
35  CoreFoundation                      0x0000000110ddf351 __CFRunLoopDoSource1 + 465
36  CoreFoundation                      0x0000000110dd7435 __CFRunLoopRun + 2389
37  CoreFoundation                      0x0000000110dd6884 CFRunLoopRunSpecific + 420
38  GraphicsServices                    0x00000001151ada6f GSEventRunModal + 161
39  UIKit                               0x000000010d5e8c68 UIApplicationMain + 159
40  Appname                             0x000000010c127a33 main + 99
41  libdyld.dylib                       0x000000011261068d start + 1
)
 libc++abi.dylib: terminating with uncaught exception of type NSException

2 个答案:

答案 0 :(得分:5)

这里使用带有画外音的UIWebView也是同样的问题。我已将视图控制器添加为webview的代理,并添加了以下代码(表示树已更改),我不再有错误了:

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
}

它也适合你吗?

更新1

错误的出现频率较低,但有时仍会出现......

更新2

在加载内容时,通过画外音看不到网页视图似乎到目前为止工作......:

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    self.webView.accessibilityElementsHidden  = YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    self.webView.accessibilityElementsHidden  = NO;
}

答案 1 :(得分:4)

Swift 3版本:在UIWebViewDelegate中添加这些行:

// Prevent Accessibility Crash
func webViewDidStartLoad(_ webView: UIWebView) {
    self.webView.accessibilityElementsHidden = true
}

func webViewDidFinishLoad(_ webView: UIWebView) {
    self.webView.accessibilityElementsHidden = false
}

注意:考虑使用WKWebview而不是UIWebView。