title: How to access popup login form with Selenium in Python
body: <p>I have been trying for a while to figure out how to enter username and password in the popup-window in this exercise:</p>
  
  <p><a href="http://pentesteracademylab.appspot.com//lab/webapp/digest" rel="noreferrer">http://pentesteracademylab.appspot.com//lab/webapp/digest</a></p>
  
  <p>but I am entirely new to Selenium in Python. I found out how to click the button, so that the login form pops up:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  driver = webdriver.Firefox()
  driver.get("http://pentesteracademylab.appspot.com//lab/webapp/digest")
  driver.find_element_by_css_selector('button').click()
  </code></pre>
  
  <p>but I cannot figure out how to access that window, let alone the fields in it. I have read about <code>switch_to_frame</code> and <code>switch_to_window</code>. For windows there is the <code>window_handles</code> showing you active windows to switch to, but this only returns a single element, which I believe is the main window, not the pop up. I also tried</p>
  
  <pre><code>alert = driver.switch_to_alert()
  </code></pre>
  
  <p>to no avail. The problem is that I do not know either which kind of object the popup is (frame,window,alert or something else), and I cannot find any names referring to it in the HTML code for the webpage.</p>
  
  <p>Can anyone take me a step further?</p>