首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EarlGrey同步的问题总是超时

EarlGrey同步的问题总是超时
EN

Stack Overflow用户
提问于 2017-03-10 20:36:00
回答 1查看 934关注 0票数 2

我对伯爵的同步功能有问题。我试图为我的应用程序创建一个简单的测试示例,基本上检查登录按钮是否出现。

代码语言:javascript
复制
func testExample() {
    let success = GREYCondition(name: "Wait for action view controller", block: { () -> Bool in
        if let rootVC = UIApplication.shared.keyWindow?.rootViewController, rootVC is ValuePropsViewController {
            return true
        }
        else {
            return false
        }
    }).wait(withTimeout: 10)
    GREYAssertTrue(success, reason: "Action view controller should appear within 5 seconds")
    EarlGrey.select(elementWithMatcher: grey_accessibilityID("loginButton")).assert(grey_sufficientlyVisible())
}

但是,它总是超时,我得到以下错误消息。我检查截图和正确的屏幕显示在失败。

代码语言:javascript
复制
Exception Name: AssertionFailedException
Exception Reason: Timed out while waiting to perform assertion.
Exception with Assertion: {
  "Assertion Criteria" : "assertWithMatcher: matcherForSufficientlyVisible(>=0.750000)",
  "Element Matcher" : "(respondsToSelector(accessibilityIdentifier) && accessibilityID('loginButton'))"
}

Exception Details: Error Trace: [
  {
    "Description" : "Failed to execute block because idling resources below are busy.",
    "Description Glossary" :     {
      "animateWithDuration:delay:options:animations:completion:" : "<NSObject: 0x610000203a30> caused the App to be in busy state for 6.8 seconds.",
      "performSelector @selector(tick) on VAAppDelegate" : "Delayed performSelector caused the App to be in busy state for 2 seconds."
    },
    "Domain" : "com.google.earlgrey.GREYUIThreadExecutorErrorDomain",
    "Code" : "0",
    "File Name" : "GREYUIThreadExecutor.m",
    "Function Name" : "-[GREYUIThreadExecutor executeSyncWithTimeout:block:error:]",
    "Line" : "235",
    "TestCase Class" : "EarlGreyVidaTests.MyFirstEarlGreyTest",
    "TestCase Method" : "testExample"
  },
  {
    "Description" : "Failed to execute assertion within 30 seconds.",
    "Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
    "Code" : "4",
    "File Name" : "GREYElementInteraction.m",
    "Function Name" : "-[GREYElementInteraction assert:error:]",
    "Line" : "418",
    "TestCase Class" : "EarlGreyVidaTests.MyFirstEarlGreyTest",
    "TestCase Method" : "testExample"
  }
]

如果我关闭同步,它就能工作:

代码语言:javascript
复制
GREYConfiguration.sharedInstance().setValue(false, forConfigKey: kGREYConfigKeySynchronizationEnabled)

我做错什么了吗?当同步关闭时,我的所有测试似乎都能很好地工作。我应该把它关了吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-10 21:33:25

您不应该关闭同步-这正是EarlGrey EarlGrey的原因,并使您的测试稳定和有用。

然而,看起来你有一些动画或延迟的performSelector,EarlGrey正在跟踪,以使它总是认为你的应用程序很忙。您可以调整的一件事是,如果您查看标题GREYConfigur.h,您可以根据应用程序的行为找到可能更改的各种配置变量。

免责声明:我是伯爵的团队的一员。

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42727287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档