Xcode ui测试:staticTexts以 [英] Xcode ui test: staticTexts start with

查看:60
本文介绍了Xcode ui测试:staticTexts以的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查我的ui上是否存在以前缀开头的元素.如何在Xcode 7 UI测试中实现它?

I want to check if an element on my ui which start with a prefix is present. How is it possible to implement it in Xcode 7 UI Tests?

app.tables["AAA"].staticTexts["Fax: 0049XXXXXXXX"].exists

我在表视图单元格中有三个元素,只有一个(第三个或最后一个)以前缀Fax:0049开头.如何检查此元素的存在?

I have three element into a tableview cell and only one (the third or last one) starts with the prefix Fax: 0049. How can i check the present of this element?

我尝试过

app.tables["AAA"].cells.staticTexts.elementBoundByIndex(2).exists

但没有,有什么主意吗?干杯

But nothing, some ideas? Cheers

推荐答案

您可以使用 BEGINSWITH 谓词检查元素是否以前缀开头.

You can use a BEGINSWITH predicate to check if an element starts with a prefix.

let app = XCUIApplication()
let faxPredicate = NSPredicate(format: "label BEGINSWITH 'Fax: '")
let faxLabel = app.staticTexts.element(matching: faxPredicate)
XCTAssert(faxLabel.exists)

这里是一个工作示例,用于选择具有不同 BEGINSWITH 谓词

Here's a working example for selecting elements with a different BEGINSWITH predicate, a picker with multiple wheels.

这篇关于Xcode ui测试:staticTexts以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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