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?
div
tag within the Safari Console I see theaccessibilityValue
set asfacebook_sharing
. However, when I hover over the WebView within the iOS Simulator I can only see the theaccessibilityTitle
set as my WebView. I am able to access my WebView usingapp.otherElements["MyWebViewAccessibilityLabel"]
but I am not able to access thediv
element usingapp.otherElements["facebook_sharing"]
. Likewise,app.otherElements["facebook_sharing"]
.exists returns false. I know I must be doing something wrong here. – Straub