title: How to enter text in an iframe with Selenium and Python
body: <p>I'm trying to use Selenium with Python to automate logging in to Autodesk GBS.  I've been able to access the &quot;Sign In&quot; frame like this:</p>
  <pre><code>driver.get(&quot;https://gbs.autodesk.com/GBS/&quot;)
  btn = driver.find_element_by_link_text('Sign In')
  btn.click()
  </code></pre>
  <p>I can't seem to access the username text entry element that pops up then.  I think that it's within an iframe, but according to the number of &quot;NoSuchElementException&quot; occurrences I've gotten, none of the 3 iframes that are apparently on the page seem to hold an element with id &quot;userName&quot;.</p>
  <p>The HTML code for the text field I'm trying to access is here:</p>
  <pre><code>&lt;input id=&quot;userName&quot; name=&quot;UserName&quot; autocomplete=&quot;off&quot; aria-label=&quot;Email text field&quot; tabindex=&quot;1&quot; placeholder=&quot;name@example.com&quot; type=&quot;text&quot; autofocus=&quot;autofocus&quot; autocorrect=&quot;off&quot; autocapitalize=&quot;off&quot; data-val=&quot;true&quot; data-val-required=&quot;Please enter an email&quot; data-val-length-max=&quot;200&quot; class=&quot;form-control  customInput2 populated valid&quot;&gt;
  </code></pre>
  <p>The HTML code for the surrounding iframe (I think) is here:</p>
  <pre><code>&lt;iframe frameborder=&quot;0&quot; hspace=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;/GBS/Authentication/Authenticate?redirectUrl=%2FGBS%2FProject&amp;amp;requestMode=Setup&amp;amp;isIframe=True&quot; allowtransparency=&quot;true&quot; style=&quot;border: none; width: 345px; height: 513px;&quot;&gt;
  ...
  &lt;/iframe&gt;
  </code></pre>
  <p>I'm very new to both Selenium and Python and after two days of trying to figure this out, I'm totally lost. Any help would be <em>very</em> appreciated!</p>
  <p><strong>UPDATE:</strong>
  Thanks to suggestions from arunkvelu and arundeep chohan below, I've made a few changes to my code (posted completely below).  However it's still not able to find the username field (see the error below).  Suggestions?</p>
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.support.wait import WebDriverWait as wait
  
  PATH = &quot;C:\\Program Files (x86)\\chromedriver.exe&quot;
  driver = webdriver.Chrome(PATH)
  
  driver.get(&quot;https://gbs.autodesk.com/GBS/&quot;)
  btn = driver.find_element_by_link_text('Sign In')
  btn.click()
  
  wait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, &quot;//div[@id='oxygen-container']/iframe&quot;)))
  
  username_field = driver.find_element_by_id(&quot;userName&quot;)
  username_field.send_keys(&quot;test@mail.com&quot;)
  
  driver.find_element_by_id(&quot;verify_user_btn&quot;).click()
  
  password = driver.find_element_by_id(&quot;password&quot;)
  password.send_keys(&quot;mypassword&quot;)
  </code></pre>
  <blockquote>
  <p>File &quot;...&quot;, line 17, in  username_field = driver.find_element_by_id(&quot;userName&quot;)
  selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {&quot;method&quot;:&quot;css selector&quot;,&quot;selector&quot;:&quot;[id=&quot;userName&quot;]&quot;}
  (Session info: chrome=86.0.4240.183)</p>
  </blockquote>