gpt4 book ai didi

ios - 断言失败 : UI Testing Failure - Neither element nor any descendant has keyboard focus

转载 作者:行者123 更新时间:2023-11-29 01:19:15 32 4
gpt4 key购买 nike

我是 xcode-ui 新手,遇到一个问题。

Assertion Failure: UI Testing Failure - Neither element nor any descendant has keyboard focus. Element:
Attributes: Other 0x7f8c1cb703d0: traits: 8589934592, {{0.0, 167.0}, {375.0, 44.0}}, label: 'XXXXXXX'
Element subtree:
→Other 0x7f8c1cb703d0: traits: 8589934592, {{0.0, 167.0}, {375.0, 44.0}}, label: 'XXXXXXX'
Path to element:
→Application 0x7f8c1cb71870: {{0.0, 0.0}, {375.0, 667.0}}, label: 'A'
↳Window 0x7f8c1cb78850: Main Window, {{0.0, 0.0}, {375.0, 667.0}}
↳Other 0x7f8c1cb77470: {{0.0, 0.0}, {375.0, 667.0}}
↳Other 0x7f8c1cb68100: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
↳Other 0x7f8c1cb62260: traits: 8589934592, {{0.0, 0.0}, {375.0, }}
↳Other 0x7f8c1cd44e20: traits: 8589934592, {{0.0, 0.0}, {375.0,}}
↳Other 0x7f8c1cd45580: traits: 8589934592, {{0.0, 0.0}, {375.0,}}
↳Other 0x7f8c1cb63040: traits: 8589934592, {{0.0, 0.0}, {375.0,}}
↳ScrollView 0x7f8c1cb60e80: traits: 8589934592, {{0.0, 0.0},
↳Other 0x7f8c1cb73fc0: traits: 8589934592, {{0.0, 64.0}, {375.0}}
↳Other 0x7f8c1cb73930: traits: 8589934592, {{0.0, 124.0},
↳Other 0x7f8c1cb703d0: traits: 8589934592, label: 'XXXXXXXX'
Query chain:
→Find: Target Application 0x7f8c19c46190
Output: {
Application 0x7f8c1cb71870: {{0.0, 0.0}, {375.0, 667.0}}, label: 'App'
}
↪︎Find: Descendants matching type ScrollView
Output: {
ScrollView 0x7f8c1cb60e80: traits: 8589934592, {{0.0, 0.0}, {375.0,}}
}
↪︎Find: Descendants matching type Other
Output: {
Other 0x7f8c1cb7bb90: traits: 8589934592, {{0.0, 124.0}, {375.0,
Other 0x7f8c1cc55950: traits: 8589934592, {{0.0, 168.0}, {375.0,
Other 0x7f8c1cc55270: traits: 8589934592, {{0.0, 124.0}, {375.0,
Other 0x7f8c1cb74650: traits: 8589934592, {{0.0, 124.0}, {375.0, 44.0}}, label: 'XXXXXXXX'
Other 0x7f8c1cb703d0: traits: 8589934592, {{0.0, 167.0}, {375.0, 44.0}}, label: 'XXXXXXXX'

我录制了一个测试并播放它,但它确实有效。这里的代码:

let elementsQuery = app.scrollViews.otherElements
let a = elementsQuery.otherElements["XXXXXXXXX"]
a.tap()
app.typeText("rerererdre")
let b = elementsQuery.otherElements["YYYYYYYYY"]
b.tap()

在将文本键入 a 字段后测试崩溃。 a 和 b 是 ScrollView 中的两个文本字段。我用 app.textFields["XXXXXXXXX"] 试过了,但没有用。

有什么想法吗?干杯

“连接硬件键盘”已关闭。

最佳答案

检查文本字段“b”是否存在,也许 b 正在获取 null 值,并且使用该 null 值调用 tap() 方法。

尝试这样,

let app = XCUIApplication()
let elementsQuery = app.scrollViews.otherElements
if(elementsQuery.textFields["XXXXXXXX"].exists)
{
let x = elementsQuery.textFields["XXXXXXXX"]
x.tap()
}
if(elementsQuery.textFields["YYYYYYYY"].exists)
{
let y = elementsQuery.textFields["YYYYYYYY"]
y.tap()
}

设置断点并检查断点是否存在。

关于ios - 断言失败 : UI Testing Failure - Neither element nor any descendant has keyboard focus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34793602/

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