Maybe someone can explain the following weird (at least for me) behavior.
Background: I'm trying to test an action on the share sheet. Since it's localized (like here in German) I can't use the labels.
So I found out that when I open the share sheet with ShareLink
I can list the following images that appear:
po app.images
Find: Target Application '...'
Output: {
Application, 0x101f47d50, pid: 2257, label: '...'
}
↪︎Find: Descendants matching type Image
Output: {
Image, 0x101d720f0, {{-150.0, 283.7}, {730.0, 798.3}}
Image, 0x101d71010, {{44.7, 586.3}, {19.0, 25.7}}, label: 'Teilen'
Image, 0x101d72d50, {{20.0, 449.7}, {40.0, 40.0}}
Image, 0x101d73f50, {{19.0, 527.7}, {64.0, 64.0}}
Image, 0x101d74610, {{116.7, 527.7}, {64.0, 64.0}}
Image, 0x101d74cd0, {{214.0, 527.7}, {64.0, 64.0}}
Image, 0x101d75930, {{367.7, 647.0}, {32.0, 32.0}}
}
For me it's obvious from the coordinates and sizes, that the 4th image ({19.0, 527.7}, {64.0, 64.0}) is the Nachrichten/Message icon, followed by the Erinnerungen/Reminder icon ({116.7, 527.7}, {64.0, 64.0}) and the Mehr/More icon {214.0, 527.7}, {64.0, 64.0}. x-coordinates increase.
Now:
po app.images.element(boundBy: 3)
...
Query chain:
→Find: Target Application '...'
Output: {
Application, 0x122143750, pid: 2257, label: '...'
}
↪︎Find: Descendants matching type Image
Output: {
Image, 0x122178d50, {{-150.0, 283.7}, {730.0, 798.3}}
Image, 0x122246bd0, {{44.7, 586.3}, {19.0, 25.7}}, label: 'Teilen'
Image, 0x1221799b0, {{20.0, 449.7}, {40.0, 40.0}}
Image, 0x12217abb0, {{19.0, 527.7}, {64.0, 64.0}}
Image, 0x12217b270, {{116.7, 527.7}, {64.0, 64.0}}
Image, 0x12217b930, {{214.0, 527.7}, {64.0, 64.0}}
Image, 0x12217c590, {{367.7, 647.0}, {32.0, 32.0}}
}
↪︎Find: Element at index 3
Output: {
Image, 0x122175e10, {{19.0, 527.7}, {64.0, 64.0}}
}
But when I use tap()
to tap it, the Reminder icon is tapped and opened.
I then tried
po app.images.element(boundBy: 5)
Query chain:
→Find: Target Application 'de.kluks.PhotoTagger'
Output: {
Application, 0x122143750, pid: 2257, label: 'PhotoTagger'
}
↪︎Find: Descendants matching type Image
Output: {
Image, 0x122199e80, {{-150.0, 283.7}, {730.0, 798.3}}
Image, 0x122198da0, {{44.7, 586.3}, {19.0, 25.7}}, label: 'Teilen'
Image, 0x12219aae0, {{20.0, 449.7}, {40.0, 40.0}}
Image, 0x12219bce0, {{19.0, 527.7}, {64.0, 64.0}}
Image, 0x12219c3a0, {{116.7, 527.7}, {64.0, 64.0}}
Image, 0x12219ca60, {{214.0, 527.7}, {64.0, 64.0}}
Image, 0x12219d6c0, {{367.7, 647.0}, {32.0, 32.0}}
}
↪︎Find: Element at index 5
Output: {
Image, 0x100eb06f0, {{214.0, 527.7}, {64.0, 64.0}}
}
po app.images.element(boundBy: 6)
Query chain:
→Find: Target Application 'de.kluks.PhotoTagger'
Output: {
Application, 0x122143750, pid: 2257, label: 'PhotoTagger'
}
↪︎Find: Descendants matching type Image
Output: {
Image, 0x122332a90, {{-150.0, 283.7}, {730.0, 798.3}}
Image, 0x1223319b0, {{44.7, 586.3}, {19.0, 25.7}}, label: 'Teilen'
Image, 0x1223336f0, {{20.0, 449.7}, {40.0, 40.0}}
Image, 0x1223348f0, {{19.0, 527.7}, {64.0, 64.0}}
Image, 0x122334fb0, {{116.7, 527.7}, {64.0, 64.0}}
Image, 0x122335670, {{214.0, 527.7}, {64.0, 64.0}}
Image, 0x1223362d0, {{367.7, 647.0}, {32.0, 32.0}}
}
↪︎Find: Element at index 6
Output: {
Image, 0x1220be5b0, {{367.7, 647.0}, {32.0, 32.0}}
}
po app.images.element(boundBy: 6).tap()
...
0 elements
In my previous run I even got an Index ouf of bound
error inside tap
although listing the exact same image worked.
Is there anything strange going on inside tap()
? I'm struggling a bit to use "1 index less than it's obvious".
And before you ask why I'm doing this: my app actually sets a "last export" via a callback when the Transferable
is composed. This is not perfect since it's also set when the share action e.g. inside files is canceled, but I couldn't find a better way for setting this. Now I want to have at least that tested, that the date of last export is shown after a share action. For that I ant to tap the message icon (since this doesn't trigger anything else but simply returns to my app).