title: Python Webdriver my script won't find the button inside the iFrame
body: <p>I am trying to verify if a button is present on a webpage after I have successfully logged in.  I am using Webdriver with Python.  The button is in an iFrame.
  This is my first webdriver python program using the a page object model framework.  Not bad so far i think.</p>
  
  <p>The program successfully logs in but it won't find the iFrame.
  I need some help please.</p>
  
  <p>I receive the following error: </p>
  
  <pre><code>Error
  Traceback (most recent call last):
  File "C:\Users\riaz.ladhani\PycharmProjects\Selenium Webdriver\TestCore  01\LoginPage_TestCase.py", line 16, in test_login_valid_user
  login_page.isAdministration_present()
  File "C:\Users\riaz.ladhani\PycharmProjects\Selenium Webdriver\TestCore  01\page.py", line 44, in isAdministration_present
  content_frame = self.driver.find_element(*MainPageLocators.contentFrame)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py",  line 664, in find_element
  {'using': by, 'value': value})['value']
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py",  line 175, in execute
  self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
  raise exception_class(message, screen, stacktrace)
  NoSuchElementException: Message: Unable to locate element:  {"method":"id","selector":"testcore"}
  </code></pre>
  
  <p>My full code snipped it as follows:</p>
  
  <pre><code>    # This class is where all my locators will be defined
  from selenium.webdriver.common.by import By
  
  class MainPageLocators(object):
      GO_BUTTON = (By.ID, 'submit')
      usernameTxtBox = (By.ID, 'unid')
      passwordTxtBox = (By.ID, 'pwid')
      submitButton = (By.ID, 'button')
      AdministrationButton = (By.CSS_SELECTOR, 'div.gwt-HTML.firepath-matching-node')
      AdministrationButtonXpath = (By.XPATH, '/body/div[2]/div[2]/div/div[2]/div/div[2]/div/div[7]/div/div')
      AdministrationButtonCSS = (By.CSS_SELECTOR, '/body/div[2]/div[2]/div/div[2]/div/div[2]/div/div[7]/div/div')
      contentFrame = (By.ID, 'testcore')
  
  
  from element import BasePageElement
  from locators import MainPageLocators
  
  # This class is the base page class
  class BasePage(object):
  
  def __init__(self, driver):
      self.driver = driver
  
  # This class is the LoginPage.  All the methods for the login page are defined here
  class LoginPage(BasePage):
  
  def click_go_button(self):
      element = self.driver.find_element(*MainPageLocators.GO_BUTTON)
      element.click()
  
  def userLogin_valid(self):
      userName_textbox = self.driver.find_element(*MainPageLocators.usernameTxtBox)
      userName_textbox.clear()
      userName_textbox.send_keys("user1")
      password_textbox =  self.driver.find_element(*MainPageLocators.passwordTxtBox)
      password_textbox.clear()
      password_textbox.send_keys("Pass1")
      submitButton = self.driver.find_element(*MainPageLocators.submitButton)
      submitButton.click()
  
  # Is the Administration button present on the dashboard page
  def isAdministration_present(self):
  
      content_frame = self.driver.find_element(*MainPageLocators.contentFrame)
      self.driver.switch_to.frame(content_frame)
      administrationButtonCSS = self.driver.find_element(*MainPageLocators.AdministrationButtonCSS)
  
  
  
      # This class is the TestCase test class for the Login page where all the test cases is defined 
      import unittest
      from selenium import webdriver
      import page
  
      class LoginPage_TestCase(unittest.TestCase):
  
  def setUp(self):
      self.driver = webdriver.Firefox()
      self.driver.get("http://mypc:8080/testcore01")
  
  def test_login_valid_user(self):
      login_page = page.LoginPage(self.driver)
      login_page.userLogin_valid()
      login_page.isAdministration_present()
  </code></pre>
  
  <p>When i inspect the element in Firefox the HTML is as follows:</p>
  
  <pre><code>    &lt;body style="margin: 0px;"&gt;
      &lt;iframe id="__gwt_historyFrame" style="position: absolute; width: 0;   height: 0; border: 0;" tabindex="-1" src="javascript:''"/&gt;
      &lt;iframe id="testCore" src="javascript:''" style="position: absolute; width: 0px; height: 0px; border: medium none;" tabindex="-1"/&gt;
     &lt;div style="position: absolute; z-index: -32767; top: -20cm; width: 10cm; height: 10cm; visibility: hidden;" aria-hidden="true"/&gt;
     &lt;div class="gwt-TabLayoutPanelTab GEGQEWXCK" style="background-color: rgb(254, 255, 238);"&gt;
     &lt;div class="gwt-TabLayoutPanelTabInner"&gt;
     &lt;div class="gwt-HTML"&gt;Administration&lt;/div&gt;
  </code></pre>