title: Silverlight UI Automation issue - element cannot be found
body: <p>I need to create automated tests for a Silverlight application, I use the System.Windows.Automation namespace. My problem is the following:</p>
  
  <p>I use AutomationElement.FindFirst to locate UI elements in the UI tree:</p>
  
  <pre><code>AutomationElement toBeInvoked = browser.FindFirst(TreeScope.Descendants,
                      new PropertyCondition(AutomationElement.AutomationIdProperty, id));
  </code></pre>
  
  <p>This works for a few steps, but after it won't find anything. I inspected that after screen changes the UI tree is going to be empty, UISpy sees only the Silverlight control, but nothing more: <a href="http://img852.imageshack.us/i/silverlightissue.jpg/" rel="nofollow">screenshot</a>
  . (I've also tried to use TreeWalker, but the result was the same.) If I click manually, and inspect the elements with UISpy, everything is OK. But when I run my code, it stops (usually at the same button).</p>
  
  <p>Later I realized that if I click through manually the screens that my code will visit, and after I run it, there won't be any issue... Strange. I tried it in FF 3.6, 4.0 and IE8. The problem is the same in every browser.</p>
  
  <p>Has anyone any idea what could be wrong, or where could be the mistake? Am I missed something in my code, or the problem is in the settings of the browser?</p>
  
  <p>Thanks in advance, regards,</p>
  
  <p>Miklos</p>