title: How to load children elements for CefBrowserWindow using UIA
body: <p>I'm tring to automate a <code>Chrome Legacy Window</code>.</p>
  <pre><code>HRESULT hr = S_OK;
  CComPtr&lt;IUIAutomationElement&gt; element;
  hr = automation_-&gt;ElementFromHandle((HWND)0x00871218, &amp;element);
  
  CComPtr&lt;IUIAutomationElement&gt; resultTabElement;
  hr = element-&gt;FindFirst(TreeScope_Descendants, resultTabPatternCondition, &amp;resultTabElement);
  </code></pre>
  <p>But sometimes <code>resultTabElement</code> is empty. So I check the window using Inspect tool.</p>
  <ol>
  <li>When the application just start up
  <a href="https://i.stack.imgur.com/OCJGC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OCJGC.png" alt="enter image description here" /></a>
  Its ControlType is <code>UIA_PaneControlTypeId</code> and has no child nodes at this moment.</li>
  <li>After I expend the second node in the red rectangle, and re-click the parent node of the red tangle:
  <a href="https://i.stack.imgur.com/50otN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/50otN.png" alt="enter image description here" /></a>
  Its ControlType is changed to <code>UIA_DocumentControlTypeId</code> and has child nodes.</li>
  </ol>
  <p>So, do you know how this happens?</p>
  <p>How do I progmatically reload the <code>Chrome Legacy Window</code> and change its type from <code>UIA_PaneControlTypeId</code> to <code>UIA_DocumentControlTypeId</code>?</p>
  <hr />
  <p>Since the <code>Chrome Legacy Window</code> is changing for some reason, so I call <code>ElementFromHandle</code> on one of its ancestors, then I can get correct <code>resultTabElement</code> after the first call, although the first call is still not working just like Inspect tool.</p>