title: Python Selenium unable to locate an element after switching to frame using Firefox browser
body: <p>I am not able to locate the element inside the frame after switching to the correct frame. Here is my code, error and HTML sorce. If I right click on the frame and select <code>This Frame -&gt; Show Only This Frame</code> then I am able to find the element in the <code>default_content</code>, but I need to find it without <code>Show Only This Frame</code></p>
  <pre><code>browser.switch_to.default_content()  
  
  browser.switch_to.frame(browser.find_element_by_id('DialogFrame'))
  
  browser.find_element_by_css_selector('#_ctl12_btnExportCSV')
  </code></pre>
  <p>Error stacktrace:</p>
  <blockquote>
  <p>NoSuchElementException                    Traceback (most recent call
  last)  in 
  ----&gt; 1 browser.find_element_by_css_selector('#_ctl12_btnExportCSV')</p>
  <p>~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py
  in find_element_by_css_selector(self, css_selector)
  596             element = driver.find_element_by_css_selector('#foo')
  597         &quot;&quot;&quot;
  --&gt; 598         return self.find_element(by=By.CSS_SELECTOR, value=css_selector)
  599
  600     def find_elements_by_css_selector(self, css_selector):</p>
  <p>~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py
  in find_element(self, by, value)
  974                 by = By.CSS_SELECTOR
  975                 value = '[name=&quot;%s&quot;]' % value
  --&gt; 976         return self.execute(Command.FIND_ELEMENT, {
  977             'using': by,
  978             'value': value})['value']</p>
  <p>~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py
  in execute(self, driver_command, params)
  319         response = self.command_executor.execute(driver_command, params)
  320         if response:
  --&gt; 321             self.error_handler.check_response(response)
  322             response['value'] = self._unwrap_value(
  323                 response.get('value', None))</p>
  <p>~\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py
  in check_response(self, response)
  240                 alert_text = value['alert'].get('text')
  241             raise exception_class(message, screen, stacktrace, alert_text)
  --&gt; 242         raise exception_class(message, screen, stacktrace)
  243
  244     def _value_or_default(self, obj, key, default):</p>
  <p>NoSuchElementException: Message: Unable to locate element:
  #_ctl12_btnExportCSV</p>
  </blockquote>
  <p>HTML:</p>
  <p><a href="https://i.stack.imgur.com/GprcJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GprcJ.png" alt="HTML nested" /></a></p>
  <p><a href="https://i.stack.imgur.com/5stTd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5stTd.png" alt="IFrame" /></a></p>