EarlGrey 同步总是超时的问题
Problems with EarlGrey synchronization always timing out
我在使用 EarlGrey 的同步功能时遇到了问题。我正在尝试为我的应用程序创建一个简单的测试示例,基本上检查登录按钮是否显示。
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())
}
但是,它总是超时,我收到以下错误消息。我检查了屏幕截图,失败时显示的是正确的屏幕。
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"
}
]
如果我关闭同步,它会起作用:
GREYConfiguration.sharedInstance().setValue(false, forConfigKey: kGREYConfigKeySynchronizationEnabled)
我做错了什么吗?我的所有测试似乎都可以在同步关闭的情况下正常运行。我应该把它关掉吗?
您不应该关闭同步 - 这就是使 EarlGrey 成为 EarlGrey 并使您的测试稳定有用的原因。
但是,您似乎有一些 EarlGrey 正在跟踪的动画或延迟的 performSelector,以使其始终认为您的应用程序很忙。您可以调整的一件事是,如果您查看 header、GREYConfiguration.h,您会发现各种配置变量,您可能会根据应用的行为进行更改。
免责声明:我是 EarlGrey 团队的一员。
我在使用 EarlGrey 的同步功能时遇到了问题。我正在尝试为我的应用程序创建一个简单的测试示例,基本上检查登录按钮是否显示。
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())
}
但是,它总是超时,我收到以下错误消息。我检查了屏幕截图,失败时显示的是正确的屏幕。
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"
}
]
如果我关闭同步,它会起作用:
GREYConfiguration.sharedInstance().setValue(false, forConfigKey: kGREYConfigKeySynchronizationEnabled)
我做错了什么吗?我的所有测试似乎都可以在同步关闭的情况下正常运行。我应该把它关掉吗?
您不应该关闭同步 - 这就是使 EarlGrey 成为 EarlGrey 并使您的测试稳定有用的原因。
但是,您似乎有一些 EarlGrey 正在跟踪的动画或延迟的 performSelector,以使其始终认为您的应用程序很忙。您可以调整的一件事是,如果您查看 header、GREYConfiguration.h,您会发现各种配置变量,您可能会根据应用的行为进行更改。
免责声明:我是 EarlGrey 团队的一员。