title: How to access dynamically loaded contents of an iframe via selenium webdriver
body: <p>I have an iframe that is initially empty and then later on during the a course of interactions on the page loads elements into the iframe dynamically. I need to access one of these elements to progress to the next step in the workflow. I use the following code:- </p>
  
  <pre><code>driver.switchTo().frame(iframeElement);  
  Wait wait = new FluentWait(driver).withTimeout(30,TimeUnit.SECONDS).
   pollingEvery(2,TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
  
  WebElement pluginTwitterButton = wait.until(new Function() {
    public WebElement apply( WebDriver driver ) { 
      return driver.findElement( By.id("twitter") ); 
    } 
  });
  </code></pre>
  
  <p>later i need to do pluginTwitterButton.click();</p>
  
  <p>But I get the following error - org.openqa.selenium.TimeoutException: Timed out after 30 seconds waiting for xxx.xxx.TestCaseSampleReply$1@1217e615 Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-32-generic', java.version: '1.6.0_24' Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"twitter"} Command duration or timeout: 30.03 seconds</p>
  
  <p>I use firefox driver , selenium webdriver jar v.2.25.0 - the element that needs to be clicked is visible to the eye when the firefoxdriver executes, but the iframe variable doesnt get refreshed for some reason. What am I missing here?</p>