title: How to wait for a frame to load before locating an element?
body: <p>I'm trying to wait for Selenium to switch changing frames before waiting on another element. I.e.</p>
  
  <pre><code>var wait = new WebDriverWait(driver, 15);
  wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(By.Id("frameA"));
  
  var wait2 = new WebDriverWait(driver, 15);
  // wait for element within frameA to exist
  wait2.Until(ExpectedConditions.ElementExists(By.Id("elementA")));
  </code></pre>
  
  <p>If I toss in a simple <code>Thread.Sleep(1000);</code> before the second wait it functions fine, but without that I get the following error:</p>
  
  <pre><code>'unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot find context with specified id"}
      enter code here
  </code></pre>
  
  <p>Is there a better way to wait for the frame context to switch finishing before waiting for an element within that frame to be populated?</p>