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

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

有帮助吗?

解决方案

我们已经使用CAutomationElement类seaching上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;
        }
        }
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top