In my app there is a label which is contained inside a simple view.
The view has a tap recogniser which will trigger a function ("why not using a button?" you might ask..well, we had to perform some funky animation and that was our best layout to do it). The problem is that I cannot access this view for simulating a tap on it.
I can access the label with app.staticText["Enter name..."]
but if I tap on it (hoping in a propagation to the parent view).
Recording a session where I tap on the label will product an app.staticText["Enter name..."]
command but playing it back products the same error.
I have tried activating the Accessibility flat for that view in the Storyboard and giving it an ID in order to get it by using this command:
app.windows.elementMatchingType(.Any, identifier: "MyView")
but as soon this flag is checked and I run my test the app enters a sort of loop of loop displaying this message over and over:
Find: Elements matching predicate '"MyView" IN identifiers'
This view is not inside a table but in the main View. How can I gain access to it?
EDIT 1: this is the output of app.DebugDescription() (thanks to @Che for the advice):
Element subtree:
→Application 0x14e7e300: {{0.0, 0.0}, {320.0, 568.0}}, label: 'MyApp'
Window 0x14dbfef0: Main Window, {{0.0, 0.0}, {320.0, 568.0}}
Other 0x14dc0a40: traits: 8589934592, {{0.0, 0.0}, {320.0, 568.0}}
Other 0x14dc0ff0: traits: 8589934592
Other 0x14eb4f50: traits: 8589934592, {{0.0, 0.0}, {320.0, 568.0}}
Other 0x14eb53d0: traits: 8589934592
Button 0x14eb5940: traits: 8589934593, {{12.0, 26.0}, {30.0, 30.0}}, label: 'home hamburger'
Image 0x14eb5f00: traits: 8589934596, {{16.0, 30.0}, {22.0, 22.0}}, identifier: 'home_hamburger'
Other 0x14eb64c0: traits: 8589934592, {{0.0, 109.0}, {320.0, 459.0}}
Other 0x14eb6a20: traits: 8589934592, {{16.0, 167.0}, {288.0, 84.0}}
Image 0x14eb6f80: traits: 8589934596, {{59.0, 184.0}, {201.0, 50.0}}, identifier: 'main_logo'
Other 0x14eb4850: traits: 8589934592, {{16.0, 254.0}, {288.0, 60.0}}
StaticText 0x14eb79e0: traits: 8589934656, {{57.0, 264.0}, {160.0, 40.0}}, label: 'Enter name...'
Image 0x14eb7f90: traits: 8589934596, {{31.0, 275.0}, {18.0, 18.0}}, identifier: 'SearchIcon'
Other 0x14eb8530: traits: 8589934592, {{57.0, 274.0}, {2.0, 20.0}}
Other 0x14eb8ac0: traits: 8589934592, {{16.0, 262.0}, {288.0, 44.0}}
Image 0x14eb9060: traits: 8589934596, {{16.0, 262.0}, {288.0, 44.0}}
SearchField 0x14eb9610: traits: 146029151232, {{24.0, 270.0}, {272.0, 28.0}}
Other 0x14eb9bc0: traits: 8589934592
Other 0x14eba170: traits: 8589934592
Window 0x14eba730: {{0.0, 0.0}, {320.0, 568.0}}
StatusBar 0x14ebaca0: {{0.0, 0.0}, {320.0, 20.0}}
Other 0x14ebb220: {{0.0, 0.0}, {320.0, 20.0}}
Other 0x14ebb7b0: {{0.0, 0.0}, {320.0, 20.0}}
Other 0x14ebbd50: traits: 8388608, {{6.0, 0.0}, {35.0, 20.0}}, label: '3 of 5 bars, signal strength'
Other 0x14ebc330: traits: 8388608, {{44.0, 0.0}, {73.0, 20.0}}, label: 'vodafone UK network'
Other 0x14ebc8c0: traits: 8388608, {{122.0, 0.0}, {13.0, 20.0}}, label: '3 of 3 Wi-Fi bars', value: SSID
Other 0x14ebce50: traits: 8389120, {{146.0, 0.0}, {32.0, 20.0}}, label: '11:34'
Other 0x14ebd3d0: traits: 8388608, {{282.0, 0.0}, {33.0, 20.0}}, label: '100% battery power, Charging'
Path to element:
→Application 0x14e7e300: {{0.0, 0.0}, {320.0, 568.0}}, label: 'MyApp'
Query chain:
→Find: Target Application 0x14ea2c00
Output: {
Application 0x14e7e300: {{0.0, 0.0}, {320.0, 568.0}}, label: 'MyApp'
}
Do you have access to another elements in your app? Can you successfully tap on smth? You can see your app hierarchy by
let app = XCUIApplication()
print(app.debugDescription)
and try to understand where is your view and what elementtype it is (eg it can be .otherElement :))
According to log output you've provided there is no view with MyView
identifier.
You can set it with a help of accessibilityIdentifier
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With