0

I have simple page: http://jstest.sytes.net/Test1.html and I need to access/get dynamically created elements from DOM via WebBrowser WinForms control

When I try to get it by:

HtmlElementCollection divs = webBrowser1.Document.GetElementsByTagName("div");

it returns only 2 divs ('container', 'inner') but I need get 2 others created by javascript ('class1', 'class2'

Appreciate any help!

ihorko
  • 6,855
  • 25
  • 77
  • 116
  • 1
    Use the `DocumentCompleted` event, as shown [here](https://stackoverflow.com/a/53218064/7444103), for example (see the other notes, too, these also may come in handy) and apply this: [How can I get the WebBrowser control to show modern contents?](https://stackoverflow.com/a/38514446/7444103). – Jimi Jun 05 '20 at 13:08
  • Yes, I wait until document completed, I try to get elements in webbrowser DocumentCompleted event – ihorko Jun 05 '20 at 13:11
  • Both parts are needed. Apply the registry settings too, otherwise your scripts won't work correctly. You can get a ready-to-use implementation [here](https://stackoverflow.com/a/59859511/7444103). Note that the `FEATURE_GPU_RENDERING` key value may not be there already, so you need to add code that check for its existence and adds it or just remove that method call, since it won't be useful here. You can implement it later. – Jimi Jun 05 '20 at 13:12

0 Answers0