华廷与网页浏览器 [英] WatiN with webbrowser
本文介绍了华廷与网页浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用下面的code结合华廷就在WinForm一个网页浏览器。
I'm using the following code to bind watin to a webbrowser on the winform.
Dim w As IE = New IE(WebBrowser1.ActiveXInstance)
Settings.AutoStartDialogWatcher = False
w.GoTo("http://google.com")
我可以从Wireshark的看到,在网页获取的加载,但形式被冻结,直到一个异常被抛出的超时而Internet Explorer的忙。
I can see from wireshark that the page get's loaded, but the form is frozen until a exception gets thrown "Timeout while Internet Explorer busy".
有没有办法绑定华廷到WebBrowser控件?
Is there a way to bind watin to the webbrowser control ?
推荐答案
首先,我认为这行:
Settings.AutoStartDialogWatcher = False
应该是在一开始,将创建即
实例前。
如果您在不同的线程中运行它你code会工作。
Your code will work if you run it in separate thread.
在C#code(不好意思):
Code in C# (sorry):
var thread = new Thread(() =>
{
Settings.AutoStartDialogWatcher = false;
var ie = new IE(webBrowser1.ActiveXInstance);
ie.GoTo("http://www.google.com");
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
这篇关于华廷与网页浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文