I use WebBrowser.Document.DomDocument and found that it has different DOM model that I can see in IE Debug Tool.
IE Debug Tool contains the valid actual DOM model while WebBrowser.Document.DomDocument doesn’t contain some elements added dynamically by JavaScript.
Actually the WebBrowser control displays all elements, even those that were added dynamically, but WebBrowser.Document.DomDocument contains outdated DOM model.
IE Debug Tool can display the actual modified DOM model at it’s current state, how to get the current DOM model using WebBrowser component?
There definitively should be a way to do it.
This question could use better documentation. But this is a pretty classic problem, it is a timing issue. You no doubt access the DomDocument property too early, typically you’d do so in the browser’s DocumentCompleted event. That’s roughly the time the javascript code starts executing. So you’ll get the version of the DOM before the changes made by the script.
There’s no decent way to deal with the problem. Execution of Javascript is entirely asynchronous and there are no events to indicate any scripting code started or stopped running. The only decent thing you can do is “wait a while”, use a timer. Preferably repeatedly until you see a good indication from the DOM that the script is done making its changes.