gpt4 book ai didi

ios - XCUIElement#typeText 对于两个文本字段失败

转载 作者:行者123 更新时间:2023-11-29 05:21:30 27 4
gpt4 key购买 nike

我在 Xcode 11.1 上观察到 XCUITest 的奇怪行为。我只有一个带有两个 UITextField 的 Storyboard,两个 UITextField 都带有可访问性标识符集。我想在两者中输入文本:

    class ExampleUITests: XCTestCase {  

func testTypingInTextField() {
let app = XCUIApplication()
app.launch()

let field1 = app.textFields["Field1"]
field1.tap()
field1.typeText("foo")

let field2 = app.textFields["Field2"]
field2.tap()
field2.typeText("bar")
}

}

在第二个字段中键入内容失败,并出现以下错误,并且光标在第二个文本字段中闪烁:

    Failed to synthesize event: Neither element nor any descendant has keyboard focus. Event dispatch snapshot: TextField, label: 'Field2'  
Element debug description:
Attributes: TextField, {{10.0, 72.0}, {355.0, 34.0}}, label: 'Field2'
Element subtree:
→TextField, 0x600000cde760, {{10.0, 72.0}, {355.0, 34.0}}, label: 'Field2'
Path to element:
→Application, 0x600000cddf80, pid: 50581, label: 'CO2Rechner'
↳Window (Main), 0x600000cddea0, {{0.0, 0.0}, {375.0, 667.0}}
↳Other, 0x600000cddce0, {{0.0, 0.0}, {375.0, 667.0}}
↳Other, 0x600000cdddc0, {{0.0, 0.0}, {375.0, 667.0}}
↳Other, 0x600000cdf020, {{0.0, 0.0}, {375.0, 667.0}}
↳Other, 0x600000cde920, {{10.0, 30.0}, {355.0, 76.0}}
↳TextField, 0x600000cde760, {{10.0, 72.0}, {355.0, 34.0}}, label: 'Field2'
Query chain:
→Find: Target Application 'com.example.CO2Rechner'
Output: {
Application, pid: 50581, label: 'CO2Rechner'
}
︎Find: Descendants matching type TextField
Output: {
TextField, {{10.0, 30.0}, {355.0, 34.0}}, label: 'Field1', value: foo
TextField, {{10.0, 72.0}, {355.0, 34.0}}, label: 'Field2'
}
︎Find: Elements matching predicate '"Field2" IN identifiers'
Output: {
TextField, {{10.0, 72.0}, {355.0, 34.0}}, label: 'Field2'
}

如果我删除在 field1 中输入的代码,它就可以工作。

我上传了example project here

我在这里想念什么?

最佳答案

模拟器中的“硬件»删除所有内容和设置”修复了问题。可能是 Beta 版留下的一些东西。

关于ios - XCUIElement#typeText 对于两个文本字段失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58648283/

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