我间歇性地收到未处理的 DOMException 105。它只在运行我的 UI 测试时发生。
如果我注释掉 UIWebView 的 loadHTMLString:baseURL 调用,则不再发生异常。
这使我的测试非常不可靠。关于如何解决这个问题有什么建议吗?
堆栈跟踪:
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
最佳答案
这里使用带画外音的 UIWebView 也有同样的问题。我已经将我的 View Controller 添加为 webview 的委托(delegate)并添加了以下代码(以指示树已更改)并且我不再有错误:
- (void)webViewDidStartLoad:(UIWebView *)webView
{
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
}
它也适合你吗?
更新 1
该错误出现的频率较低,但有时仍会出现...
更新 2
到目前为止,在加载其内容时通过画外音使 webview 不可见似乎是可行的……:
- (void)webViewDidStartLoad:(UIWebView *)webView
{
self.webView.accessibilityElementsHidden = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
self.webView.accessibilityElementsHidden = NO;
}
关于ios - DOMException 105 仅在 UI 测试期间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41478330/
很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
我正在使用i18n从头开始构建一个多语言网络应用程序,虽然我自己可以处理一大堆yml文件,但我说的语言(非常)有限,最终我想寻求外部帮助帮助。我想知道这里是否有人在使用UI插件/gem(与django上的django-rosetta不同)来处理多个翻译器,其中一些翻译器不愿意或无法处理存储库中的100多个文件,处理语言数据。谢谢&问候,安德拉斯(如果您已经在rubyonrails-talk上遇到了这个问题,我们深表歉意) 最佳答案 有一个rails3branchofthetolkgem在github上。您可以通过在Gemfi
我正在编写一个包含C扩展的gem。通常当我写一个gem时,我会遵循TDD的过程,我会写一个失败的规范,然后处理代码直到它通过,等等......在“ext/mygem/mygem.c”中我的C扩展和在gemspec的“扩展”中配置的有效extconf.rb,如何运行我的规范并仍然加载我的C扩展?当我更改C代码时,我需要采取哪些步骤来重新编译代码?这可能是个愚蠢的问题,但是从我的gem的开发源代码树中输入“bundleinstall”不会构建任何native扩展。当我手动运行rubyext/mygem/extconf.rb时,我确实得到了一个Makefile(在整个项目的根目录中),然后当
我有一个围绕一些对象的包装类,我想将这些对象用作散列中的键。包装对象和解包装对象应映射到相同的键。一个简单的例子是这样的:classAattr_reader:xdefinitialize(inner)@inner=innerenddefx;@inner.x;enddef==(other)@inner.x==other.xendenda=A.new(o)#oisjustanyobjectthatallowso.xb=A.new(o)h={a=>5}ph[a]#5ph[b]#nil,shouldbe5ph[o]#nil,shouldbe5我试过==、===、eq?并散列所有无济于事。
我有一些Ruby代码,如下所示:Something.createdo|x|x.foo=barend我想编写一个测试,它使用double代替block参数x,这样我就可以调用:x_double.should_receive(:foo).with("whatever").这可能吗? 最佳答案 specify'something'dox=doublex.should_receive(:foo=).with("whatever")Something.should_receive(:create).and_yield(x)#callthere
Sinatra新手;我正在运行一些rspec测试,但在日志中收到了一堆不需要的噪音。如何消除日志中过多的噪音?我仔细检查了环境是否设置为:test,这意味着记录器级别应设置为WARN而不是DEBUG。spec_helper:require"./app"require"sinatra"require"rspec"require"rack/test"require"database_cleaner"require"factory_girl"set:environment,:testFactoryGirl.definition_file_paths=%w{./factories./test/
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我已经构建了一些serverspec代码来在多个主机上运行一组测试。问题是当任何测试失败时,测试会在当前主机停止。即使测试失败,我也希望它继续在所有主机上运行。Rakefile:namespace:specdotask:all=>hosts.map{|h|'spec:'+h.split('.')[0]}hosts.eachdo|host|begindesc"Runserverspecto#{host}"RSpec::Core::RakeTask.new(host)do|t|ENV['TARGET_HOST']=hostt.pattern="spec/cfengine3/*_spec.r
我在app/helpers/sessions_helper.rb中有一个帮助程序文件,其中包含一个方法my_preference,它返回当前登录用户的首选项。我想在集成测试中访问该方法。例如,这样我就可以在测试中使用getuser_path(my_preference)。在其他帖子中,我读到这可以通过在测试文件中包含requiresessions_helper来实现,但我仍然收到错误NameError:undefinedlocalvariableormethod'my_preference'.我做错了什么?require'test_helper'require'sessions_hel
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下