【问题标题】:Web Automation Using MSHTML使用 MSHTML 的 Web 自动化
【发布时间】:2010-12-27 22:53:40
【问题描述】:

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

请分享您在 MSHTML 自动化方面的经验。谢谢。

【问题讨论】:

    标签: html xml automation mshtml webautomation


    【解决方案1】:

    我们使用 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-09-10
      • 2016-06-20
      • 2020-09-30
      • 2019-04-05
      • 2022-01-07
      • 2013-02-13
      • 2012-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多