它们是UILabel,除了长描述是UITextVIEw.
在我想要做的页面断言测试答案中的值.
对于UILabels的答案很好.我可以关注 Xcode UI Test example
只需点击元素并将方法从.tap()更改为.exist()然后通过assert()将其括起来,该方法非常容易理解.
我的问题是UITextVIEw比UILabel更复杂.
如何获取UITextVIEw的值以进行断言检查?
func testG(){let app = XCUIApplication()app.launch();app.buttons["Enter"].tap()app.tables.staticTexts["Bee"].tap()assert(app.scrollVIEws.staticTexts["name :"].exists);assert(app.scrollVIEws.staticTexts["Age :"].exists);assert(app.scrollVIEws.staticTexts["Specialty :"].exists);assert(app.scrollVIEws.staticTexts["Description :"].exists);assert(app.scrollVIEws.staticTexts["Bee"].exists);assert(app.scrollVIEws.staticTexts["11"].exists);assert(app.scrollVIEws.staticTexts["Sky diver"].exists);let text = "Bees are flying insects closely related to wasps and ants,kNown for their role in pollination and,in the case of the best-kNown bee specIEs,the European honey bee,for producing honey and beeswax. Bees are a monophyletic lineage within the superfamily ApoIDea,presently consIDered as a clade Anthophila. There are nearly 20,000 kNown specIEs of bees in seven to nine recognized familIEs,[1] though many are undescribed and the actual number is probably higher. They are found on every continent except Antarctica,in every habitat on the planet that contains insect-pollinated flowering plants.EOF";assert(app.scrollVIEws.childrenMatchingType(.TextVIEw).element.exists);}解决方法 如果其他人发现这个问题,我可以通过使用获得UITextVIEw的文本
app.textVIEws.element.value as? String
这假设当时屏幕上只有一个文本视图.
总结以上是内存溢出为你收集整理的如何在XCode7 iOS9中断言TextView值?全部内容,希望文章能够帮你解决如何在XCode7 iOS9中断言TextView值?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)