title: Ways to deal with #document under iframe
body: <p>For the portal I am testing now, I came with the problem that I could not create any xpath locators, after some time I figured out that it was because of an '#document', this cuts the path and makes the simple "copy xpath" to direct the path to a completely different element.</p>
  
  <pre><code>&lt;iframe id="FRAMENAME" src="/webclient/workspace/launch-task/REMbl?ds=BP" width="100%" height="100%" frameborder="0" data-navitemname="navitemname" style="" xpath="1"&gt;
  #document
      &lt;html&gt;
          CODE....
      &lt;/html&gt;
  </code></pre>
  
  <p></p>
  
  <p>I found the solution for this is it is simply add a switchTo like this:</p>
  
  <pre><code>driver.switchTo().frame("FRAMENAME");
  </code></pre>
  
  <p>This works and makes the rest of the code to work properly but, takes some extra time processing this command till the code moves to the next line.</p>
  
  <p>So I would like to ask, is there is a better solution for this? something smarter/faster?</p>
  
  <p>I am concerned that when the point where I have lots of scripts comes, the execution time will take too long.</p>
  
  <p>I don't use id locators for example because they are all dynamic so sometimes a xpath is required.</p>
  
  <p>Thank you!</p>