辅助功能 API:AXWebArea 子元素(或 HTML 源)
我需要使用 Cocoa Accessibility API 从第三方应用程序获取信息。第三方应用程序使用 WebView 显示其用户界面(AXWebArea
角色)。此 AXUIElement 没有子元素。
if ([role isEqualToString:@"AXWebArea"])
{
NSArray *names;
AXUIElementCopyAttributeNames(foundElement, (CFArrayRef *)&names);
NSLog(@"%@", names);
}
此代码输出:
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
为空,因此我无法访问 AXWebArea
UI 元素内的 HTML 元素。我如何访问它们?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定网页内容已加载吗?
我刚刚用 Safari 做了一个小实验。
加载[此页面][1]后,辅助功能检查器显示 AXChildren 有 83 个项目,AXLinkUIElements 有 121 个项目。
但是当我切换到加载了 about:blank 的选项卡时,它显示了 0 个项目。
在我的开发环境中,辅助功能检查器应用程序位于
/Developer/Applications/Utilities/Accessibility\ Tools/
。[1]: 辅助功能 API:AXWebArea 子元素(或 HTML 源)< /a>,即这一页。
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.