I am trying to find a way to tap a link with the following HTML structure:
<a>
<div id="facebook_sharing"></div>
</a>
The a
tag does not have any attributes or text associated with it, just the div
tag inside.
I have tried the following but with no success:
app.links["facebook_sharing"].tap()
Is there a way to find the div
tag element and tap on it?
Thanks!
Xcode UI Testing interacts with your app via accessibility. Just like it doesn't have access to the underlying UIKit elements, it doesn't have direct access to the HTML DOM. You cannot expect the framework to know about something in your markup unless that gets exposed to accessibility in some way.
To "see the app as UI Testing does" open Accessibility Inspector.app on your mac. (You can easily find this by searching for it in Spotlight.) Then, hover over the div
with your cursor. If you see any of the following attributes set you can query for the element:
accessibilityTitle
accessibilityPlaceholderValue
accessibilityLabel
accessibilityValue
If none of these are set on the a
or div
elements you should update them yourself. Think of it this way. If someone who is visually impaired uses the site, how will he/she know that he/she can interact with the Facebook link?
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