如何在XCode7 iOS9中断言TextView值?
发布时间:2020-12-14 19:35:43 所属栏目:百科 来源:网络整理
导读:我正在进行UI单元测试.在图片里. 它们是UILabel,除了长描述是UITextView. 在我想要做的页面断言测试答案中的值. 对于UILabels的答案很好.我可以关注 Xcode UI Test example 只需点击元素并将方法从.tap()更改为.exist()然后通过assert()将其括起来,该方法非
我正在进行UI单元测试.在图片里.
它们是UILabel,除了长描述是UITextView. 在我想要做的页面断言测试答案中的值. 对于UILabels的答案很好.我可以关注 Xcode UI Test example 只需点击元素并将方法从.tap()更改为.exist()然后通过assert()将其括起来,该方法非常容易理解. 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 这假设当时屏幕上只有一个文本视图. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ruby-on-rails – Rails 3.1,Postgres 9.1.4,hstore未知运算
- ruby-on-rails – 安装Phusion Passenger的Amazon Linux堆栈
- 当我访问超出我分配的内存时,为什么我没有得到堆栈粉碎错误
- Flex组件生命周期(整理版)
- unity基础开发----常用代码Unity中解析XML
- 统计代码的行数
- 《从零开始学Swift》学习笔记(Day 63)――Cocoa Touch设计
- [cocos2dx_Lua]quick中的触摸事件
- postgresql共享内存之——分片(slice)
- flex builder 4 一些配置环境的问题(版本、连接调试器 57%