【发布时间】:2010-12-27 22:53:40
【问题描述】:
我们希望自动化在 asp.net 中开发的 Web 应用程序。为了使这个站点自动化,我们计划使用 MSHTML。但在最终确定 MSHTML 之前,我想知道 MSHTML 是否存在任何已知限制,或者请分享我们可能无法使用 MSHTML 自动化的控件列表。
请分享您在 MSHTML 自动化方面的经验。谢谢。
【问题讨论】:
标签: html xml automation mshtml webautomation
我们希望自动化在 asp.net 中开发的 Web 应用程序。为了使这个站点自动化,我们计划使用 MSHTML。但在最终确定 MSHTML 之前,我想知道 MSHTML 是否存在任何已知限制,或者请分享我们可能无法使用 MSHTML 自动化的控件列表。
请分享您在 MSHTML 自动化方面的经验。谢谢。
【问题讨论】:
标签: html xml automation mshtml webautomation
我们使用 CAutomationElement 类来搜索 webDocument 上的元素并识别表格和不同的控件。部分示例代码如下:
if (parentElement != null)
{
string description = string.Empty;
switch (elementInformation.SearchBy)
{
case SearchByType.Name:
description = parentElement.Name;
break;
case SearchByType.ID:
description = parentElement.AutomationId;
break;
}
if (description != null && description.Equals(elementInformation.ElementDescription.Trim()))
{
searchedElement = parentElement;
}
else
{
List<IWebElement> children = parentElement.Children;
foreach (IWebElement childElement in children)
{
IWebElement tempElement = SearchHtmlElement(childElement, elementInfo);
if (tempElement != null)
{
searchedElement = tempElement;
break;
}
}
}
【讨论】: