我们想要自动化在asp.net中开发的web应用程序。为了自动化这个网站,我们计划使用MSHTML。但在最终确定MSHTML之前,我想知道MSHTML是否有任何已知的限制,或者请分享我们可能无法使用MSHTML自动化的控件列表。
请分享您使用MSHTML自动化的经验。谢谢。
发布于 2010-02-19 02:11:15
我们使用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;
}
}
}https://stackoverflow.com/questions/1926669
复制相似问题