1

我有一个应用程序可以在页面加载时动态加载 iframe。当我使用 Web 浏览器控件对该应用程序进行自动化时,我收到脚本错误,因为 java 脚本未完全加载到 iframe 中。

我在 DocumentCompleted 事件中检查浏览器的就绪状态,仍然没有运气......

 if (this.browser.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete)
            return;
        else
        {
 // do automation
  }
4

1 回答 1

0

You can try with this code, encapsulte this in boolean property

            if (this.WebBrowser.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete)
                return false;

            if (this.HtmlDomDocument == null)
                return false;

            foreach (IHTMLDOMNode node in this.HtmlDomDocument.all)
            {
                IHTMLFrameBase2 frame = node as IHTMLFrameBase2;
                if (frame != null)
                {
                    if (!frame.readyState.Equals("complete", StringComparison.OrdinalIgnoreCase))
                        return false;
                }
            }

            return true;
于 2012-08-28T13:29:13.417 回答