首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MSHTML的Web自动化

使用MSHTML的Web自动化
EN

Stack Overflow用户
提问于 2009-12-18 14:25:56
回答 1查看 1.3K关注 0票数 0

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-02-19 02:11:15

我们使用CAutomationElement类在webDocument上搜索元素,并确定表和不同的控件。下面是一些示例代码:

代码语言:javascript
复制
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;
        }
        }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1926669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档