WatiN with webbrowser

跟風遠走 提交于 2019-12-08 05:18:45

问题


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")

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".

Is there a way to bind watin to the webbrowser control ?


回答1:


First of all, I think that this line:

Settings.AutoStartDialogWatcher = False

should be at the beginning, before IE instance is created.

Your code will work if you run it in separate thread.

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();



回答2:


If I use this code it works

ie = New IE(WebBrowser1.ActiveXInstance)
ie.GoToNoWait("http://google.com")
While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
  Application.DoEvents()
End While

If it is not the best solution, but it works for me



来源:https://stackoverflow.com/questions/3712599/watin-with-webbrowser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!