标签: earlgrey

如何配置我的EarlGrey测试以等待视图或事件?

我正在编写一个测试,我需要等待特定视图使用EarlGreyUI测试框架在我的UI中显示.所以,我在这里查看了文档,并尝试使用它GREYCondition.但似乎GREYCondition需要使用特定条件检查等.任何人都可以告诉我这种情况的格式是什么?有什么方法可以让我在我的观点中通过条件让它等待它?

testing functional-testing ios earlgrey

5
推荐指数
1
解决办法
2090
查看次数

使用 EarlGrey 按导航栏上的后退按钮

我在尝试编写一个使用后退按钮的测试时遇到了一些障碍,希望有人能用这个为我指明正确的方向。

我的视图非常标准,我有一个 UINavigation 控制器作为我的根视图控制器,我将其推到某个点,然后需要返回。

我尝试制作一个匹配器来查找导航栏中的后退按钮,但没有取得任何成功。我尝试使用标签、id 和值,在后退按钮项上设置可访问性标识符并未导致匹配,即使它适用于我的其他界面元素。

[self.navigationItem.backBarButtonItem setAccessibilityIdentifier:@"Back"];
Run Code Online (Sandbox Code Playgroud)

在我的测试中我有以下内容:

// Press the back button

id<GREYMatcher> backMatcher =
    grey_allOf(grey_accessibilityID(@"Back"), grey_sufficientlyVisible(), nil);

[[EarlGrey selectElementWithMatcher:backMatcher] performAction:grey_tap()];
Run Code Online (Sandbox Code Playgroud)

我使用断点和PO进行更深入的研究,发现后退按钮的accessibilityLabel确实设置为@“Back”,但它与以下代码也不匹配。

// Press the back button

id<GREYMatcher> backMatcher =
    grey_allOf(grey_accessibilityID(@"Back"), grey_sufficientlyVisible(), nil);

[[EarlGrey selectElementWithMatcher:backMatcher] performAction:grey_tap()];
Run Code Online (Sandbox Code Playgroud)

testing ios earlgrey

5
推荐指数
1
解决办法
1524
查看次数

是否可以使用EarlGrey(iOS UI测试)解除系统警报?

我开始尝试使用EarlGrey一点点,现在已经使用XCUITest进行了UI测试.我遇到了无法解除系统警报的经典问题,这很奇怪,因为看起来Google实现了一个名为grey_systemAlertViewShown()的系统警报匹配器.我正在尝试使用GREYCondition检测系统警报.这是我尝试过的:

    - (void)waitForAndDismissSystemAlertForSeconds:(NSInteger)seconds {
    GREYCondition *interactableCondition = [GREYCondition conditionWithName:@"isInteractable" block:^BOOL{
        // Fails if element is not interactable
        NSError *error;
        [[EarlGrey selectElementWithMatcher:grey_systemAlertViewShown()] assertWithMatcher:grey_interactable() error:&error];

        if (error) {
            return NO;
        } else {
            NSError *allowButtonError;
            [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Allow")] assertWithMatcher:grey_notNil() error:&allowButtonError];
            if (!allowButtonError) {
                [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Allow")] performAction:grey_tap()];
               }

        return YES;
    }];

    [interactableCondition waitWithTimeout:seconds];
}
Run Code Online (Sandbox Code Playgroud)

我也尝试过使用这里描述的addUIInterruptionMonitorWithDescription(但是使用EarlGrey代码来完成我在上面的中断监视器中所做的事情):Xcode 7 UI测试:如何在代码中解除一系列系统警报

两种方法都不奏效.我的GREYCondition中的非错误情况不会触发断点,并且中断监视器也不会解除我的警报.

有人知道EarlGrey是否支持解雇系统警报?

ui-testing ios earlgrey

4
推荐指数
1
解决办法
1385
查看次数

EarlGrey 尝试等待 5.0 秒让应用程序达到空闲状态

看来EarlGrey在测试我们的APP时不能使用等待APP空闲的好功能。在每个屏幕上出现此错误:

EarlGrey 尝试等待 5.0 秒让应用程序达到空闲状态,但没有成功。EarlGrey 现在被迫清理状态跟踪器,因为测试 -[EGT testLogin] 可能导致 UI 线程无限期地处于非空闲状态

现在我禁用了该功能并且一切正常,但无法理解此类问题的原因是什么。我在 Xcode 7 UI 自动化上遇到了同样的问题,但仅在整个应用程序的 1 个屏幕上(因为一些大量数据获取器)而不是在欢迎页面上。

这是 AppStateTracker 的状态:

Waiting for a draw/layout pass to complete
Waiting for root UIViewController to appear
Run Code Online (Sandbox Code Playgroud)

ios earlgrey

3
推荐指数
1
解决办法
1026
查看次数

如何在使用 EarlGrey 自动化时执行拉动刷新?

假设您有一个 tableView 或 fileListView,并且您想对其执行拉动刷新操作。尝试通过滑动和滚动执行,最初没有结果。

earlgrey

2
推荐指数
1
解决办法
310
查看次数

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())
}
Run Code Online (Sandbox Code Playgroud)

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

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'))"
} …
Run Code Online (Sandbox Code Playgroud)

earlgrey

1
推荐指数
1
解决办法
611
查看次数

标签 统计

earlgrey ×6

ios ×4

testing ×2

functional-testing ×1

ui-testing ×1