Reputation: 5129
i'm new im xcode-ui and have one problem.
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'
I recorded a test an play it, but it did work. Here the code:
let elementsQuery = app.scrollViews.otherElements
let a = elementsQuery.otherElements["XXXXXXXXX"]
a.tap()
app.typeText("rerererdre")
let b = elementsQuery.otherElements["YYYYYYYYY"]
b.tap()
The test crash after it typed the text into the a field. a and b are two textfield in a scrollviews. I tried it with app.textFields["XXXXXXXXX"] but it didn't work.
Any ideas? Cheers
The "Connect hardware keyboard" is off.
Upvotes: 0
Views: 1896
Reputation: 376
Check the existence of the textfield 'b' maybe b is getting value null and with that null value you are calling tap() method.
try like this,
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()
}
Put a breakpoint and check whether it exists or not.
Upvotes: 1