如何在iOS 9模拟器中关闭辅助功能检查器? [英] How do I turn off the Accessibility Inspector in the iOS 9 simulator?

查看:261
本文介绍了如何在iOS 9模拟器中关闭辅助功能检查器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的KIF测试打开了可访问性检查器(显然,KIF必须工作。)问题是,它的窗口遮挡了一些随后需要执行的UI测试的控件,这些测试失败了。

The accessibility inspector is turned on by my KIF tests (apparently it's necessary for KIF to work.) Problem is, its window occludes controls some subsequent UI tests need to tap on and those tests fail.

使用KIF测试完成后如何关闭辅助功能检查器,以便可以运行UI测试?

How can I turn the Accessibility Inspector off when my KIF tests are done with it so my UI Tests can run?

(在模拟器的设置应用中手动关闭它不是解决方案,我正在寻找可以从代码中调用,在目标中设置或...的东西?)

推荐答案

我在 Stew Gleadow的博客

您只需要更改以下行:

CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanFalse, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost); 

kCFBooleanTrue 更改为 kCFBooleanFalse

+ (void)_enableAccessibilityInSimulator {
    NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
    NSString *appSupportLocation = @"/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport";

    NSDictionary *environment = [[NSProcessInfo processInfo] environment];
    NSString *simulatorRoot = [environment objectForKey:@"IPHONE_SIMULATOR_ROOT"];
    if (simulatorRoot) {
        appSupportLocation = [simulatorRoot stringByAppendingString:appSupportLocation];
    }

    void *appSupportLibrary = dlopen([appSupportLocation fileSystemRepresentation], RTLD_LAZY);

    CFStringRef (*copySharedResourcesPreferencesDomainForDomain)(CFStringRef domain) = dlsym(appSupportLibrary, "CPCopySharedResourcesPreferencesDomainForDomain");

    if (copySharedResourcesPreferencesDomainForDomain) {
        CFStringRef accessibilityDomain = copySharedResourcesPreferencesDomainForDomain(CFSTR("com.apple.Accessibility"));

        if (accessibilityDomain) {
            CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanFalse, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
            CFRelease(accessibilityDomain);
        }
    }

    [autoreleasePool drain];
}

这篇关于如何在iOS 9模拟器中关闭辅助功能检查器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆