gpt4 book ai didi

ios - 如何在 XCode7 iOS9 中断言 TextView 值?

转载 作者:搜寻专家 更新时间:2023-10-30 22:15:18 27 4
gpt4 key购买 nike

我正在进行 UI 单元测试。在图片里。
它们是 UILabel,除了长描述是 UITextView。
在页面中,我想断言测试答案中的值。

对于 UILabels 中的答案很好。我可以关注Xcode UI Test example
该方法非常容易遵循,只需点击元素并将方法从 .tap() 更改为 .exist() 然后用 assert()< 将其括起来

我的问题是 UITextViewUILabel 更复杂。
如何获取 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);
}

UI with scrollbar

最佳答案

万一其他人发现这个问题,我可以使用

获取 UITextView的文本
app.textViews.element.value as? String

这假设当时屏幕上只有一个 TextView 。

关于ios - 如何在 XCode7 iOS9 中断言 TextView 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32473074/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com