0

我们想要自动化在 asp.net 中开发的 Web 应用程序。为了使这个站点自动化,我们计划使用 MSHTML。但在最终确定 MSHTML 之前,我想知道 MSHTML 是否存在任何已知限制,或者请分享我们可能无法使用 MSHTML 自动化的控件列表。

请分享您使用 MSHTML 自动化的经验。谢谢。

4

1 回答 1

0

我们使用 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;
        }
        }
    }
于 2010-02-18T18:11:15.090 回答