title: Access Element in Iframe with Selenium
body: <p>I try to access an element via XPath, but it is not working somehow. The element is in an IFrame, could that be the reason?
  If so, what do I need to do in order to be able to access it still?
  Or might it be an issue, that I nested two html's (HTML Code Picture)? What would be a workaround for that?</p>
  
  <p>The error message I get:</p>
  
  <blockquote>
    <p>org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='oslist']/table<a href="https://i.stack.imgur.com/7Trzk.png" rel="nofollow noreferrer">1</a>/tbody/tr<a href="https://i.stack.imgur.com/j7xrG.png" rel="nofollow noreferrer">2</a>/td<a href="https://i.stack.imgur.com/j7xrG.png" rel="nofollow noreferrer">2</a>/table/tbody/tr<a href="https://i.stack.imgur.com/7Trzk.png" rel="nofollow noreferrer">1</a>/td/a"}<br/>
    Command duration or timeout: 1.14 seconds</p>
  </blockquote>
  
  <p>Java Code:</p>
  
  <pre><code> @Test
   public void testGenerierter() throws Exception {
  
       driver.findElement(By.id("cmdSigOn")).click();
       driver.findElement(By.id("k278")).click();
       driver.findElement(By.id("k279")).click();
       driver.findElement(By.id("k332")).click();
       Thread.sleep(3000);
       driver.switchTo().frame("1");
  
       Thread.sleep(3000);
       driver.findElement(By.xpath(".//*[@id='oslist']/table[1]/tbody/tr[2]/td[2]/table/tbody/tr[1]/td/a"));
       driver.findElement(By.id("LogoutButton")).click();
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7Trzk.png" rel="nofollow noreferrer">HTML Code</a></p>
  
  <p><a href="https://i.stack.imgur.com/j7xrG.png" rel="nofollow noreferrer">XPath from Firefox</a></p>