|
Prev: %CLRVERSION%
Next: FileSystemWatcher
From: jaroslaw.pawlak on 23 Jun 2008 09:53 Hello, I'm trying to automate webbrowser using webbrowser control. I have problem with pages using ajax, as when LoadComplete event is executed, ajax part is not yet loaded, and after it is loaded - webbrowser does not throw next complete event. How should I use webbrowser control in order to get document with dom uptated with the ajax part?. Thanks in advance for any ideas Jarek
From: Bim Jeam Bim on 15 Jul 2008 01:00 Don't know if this is exactly what you're after but (providing I know the target's ID or some other characteristic) I do it like this ... // Get the target (e.g) HtmlElement target = _webBrowser.Document.GetElementById("somedivthatwillbepopulatedbytheajaxrequest"); if (target != null) { target.AttachEventHandler("onpropertychange", new EventHandler(handler)); } The event will fire whenever the element is (re)populated with HTML so all you do is implement the handler so you can check the InnerHTML or InnerText or whatever it is you need to do, and do it to your hearts content (e.g) private void handler(Object sender, EventArgs e) { HtmlElement div = _webBrowser.Document.GetElementById("somedivthatwillbepopulatedbytheajaxrequest"); if (div == null) return; String x = div.InnerHtml; // etc if (!x.Equals("Loading...", StringComparison.InvariantCultureIgnoreCase)) { // Now the element has been populated, do something } } "jaroslaw.pawlak(a)gmail.com" wrote: > Hello, I'm trying to automate webbrowser using webbrowser control. > I have problem with pages using ajax, as when LoadComplete event is > executed, ajax part is not yet loaded, and after it is loaded - > webbrowser does not throw next complete event. How should I use > webbrowser control in order to get document with dom uptated with the > ajax part?. > Thanks in advance for any ideas > Jarek >
From: jaroslaw.pawlak on 22 Jul 2008 02:34 Hi, this is exactly what I need. Works fine. Thanks!
|
Pages: 1 Prev: %CLRVERSION% Next: FileSystemWatcher |