gpt4 book ai didi

ios - typeText 方法的 SwiftUI TextEditor UI 测试失败

转载 作者:行者123 更新时间:2023-12-04 08:41:17 26 4
gpt4 key购买 nike

“typeText”方法适用于“TextField”元素,但不适用于 Xcode UI 测试中的“TextEditor”元素。尝试连接硬件键盘选项(启用/禁用)但没有成功。任何解决方法?

Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: TextView, identifier: 'content'

let nameTextField = app.textFields["name"]
nameTextField.tap()
nameTextField.typeText("Test Name") // Working

let contentTextEditor = app.textViews["content"]
contentTextEditor.tap() // It successfully makes the cursor focus on the TextEditor element
contentTextEditor.typeText("Test Content") // Here is the error

最佳答案

也许你可以尝试粘贴?

let contentTextEditor = app.textViews["content"]
UIPasteboard.generalPasteboard().string = "Test Content"
contentTextEditor.doubleTap()
app.menuItems.elementBoundByIndex(0).tap() // This is the ugly, but correct way to hit the paste button
XCTAssertEqual(contentTextEditor.value as? String, "Test Content")

关于ios - typeText 方法的 SwiftUI TextEditor UI 测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64555042/

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