I need to get information from the third-party application using Cocoa Accessibility API. The third-party application uses WebView to show its user interface (AXWebArea
role). This AXUIElement has no children.
if ([role isEqualToString:@"AXWebArea"])
{
NSArray *names;
AXUIElementCopyAttributeNames(foundElement, (CFArrayRef *)&names);
NSLog(@"%@", names);
}
This code outputs:
AXRole,
AXSubrole,
AXRoleDescription,
AXChildren,
AXHelp,
AXParent,
AXPosition,
AXSize,
AXTitle,
AXDescription,
AXValue,
AXFocused,
AXEnabled,
AXWindow,
AXSelectedTextMarkerRange,
AXStartTextMarker,
AXEndTextMarker,
AXVisited,
AXLinkedUIElements,
AXSelected,
AXBlockQuoteLevel,
AXTopLevelUIElement,
AXLinkUIElements,
AXLoaded,
AXLayoutCount,
AXLoadingProgress,
AXURL
AXChildren
is empty, so I cannot access HTML elements inside the AXWebArea
UI element. How can I access them?
Are you sure the web content is loaded? I just did a little experiment with Safari. With [this page][1] loaded, the Accessibility Inspector showed AXChildren with 83 items and AXLinkUIElements with 121 items. But when I switched to a tab with about:blank loaded, it showed 0 items for both.
In my development environment the Accessibility Inspector app is at /Developer/Applications/Utilities/Accessibility\ Tools/
.
[1]: Accessibility API: AXWebArea children elements (or HTML source), i.e. this very page.