簡體   English   中英

typeText 方法的 SwiftUI TextEditor UI 測試失敗

[英]SwiftUI TextEditor UI Testing Failure for typeText method

“typeText”方法適用於“TextField”元素,但不適用於 Xcode UI 測試中的“TextEditor”元素。 嘗試連接硬件鍵盤選項(啟用/禁用)但沒有成功。 任何解決方法?

合成事件失敗:元素和任何后代都沒有鍵盤焦點。 事件調度快照:TextView,標識符:'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")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM