title: Getting an ID or other handle for a file chooser dialog box in Selenium
body: <p>There are lots of posts on SO about how to work with a file chooser in Selenium, but they all seem to think you have a reference to an element representing the file chooser dialog, often because you know the element's ID. How do you find this? My normal method, using "Inspect Element," doesn't work, because there's no way to turn Inspect Element on with the file chooser dialog up.</p>
  
  <p>The page in question is images.bing.com. The file chooser comes up when you click on the camera ("Search using an image") and then click browse.</p>
  
  <p>Here's what I've tried. I wrote this function to get a list of  all visible elements so that I could look at which elements are visible after I click the link to bring up the file chooser but not before. This process identifies three such elements, but none of them has an ID when I run <code>elem.get_attribute("id")</code> or <code>elem.get_property("id")</code>.</p>
  
  <pre><code>def get_visible_elements(self):
      result = set()
      for elem in self.driver.find_elements_by_css_selector("*"):
          try:
              if elem.is_displayed():
                  result.add(elem)
          except StaleElementReferenceException:
              pass
      return result
  </code></pre>