title: How to find an id in complex html code using Python's webdriver?
body: <p>In this complex html code, I would like to find the id="workContentWrapper" using Python's webdriver.</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;...&lt;/head&gt;
    &lt;body style="MARGIN: 0px; BACKGROUND-COLOR: #f4f4f4" onkeydown="return onBodyKeyDown(event)" onkeypress="return onBodyKeyPress(event)" onclick="onBodyClick(event)" onload="main();" onunload="handleUnload(window);" onresize="null"&gt;
      &lt;div&gt;...&lt;/div&gt;
      &lt;div id="panesLoaded" isLoaded="true"&gt;
          &lt;div&gt;...&lt;/div&gt;
          &lt;div id="workPaneWrapper" style="WIDTH: 100%; MARGIN: 0px 0px 15px"&gt;
              &lt;table cellSpacing="0" cellPadding="0" width="100%" border=0&gt;
                  &lt;tbody&gt;
                      &lt;tr&gt;
                          &lt;td&gt;...&lt;/td&gt;
                          &lt;td width="205" vAlign="top" style="BACKGROUND-COLOR: #f4f4f4" rowSpan="1" colSpan="1"&gt;
                              &lt;iframe name="oLeftPaneContent" width="&amp;{screenToggler.getSelectionPaneWidth()};%" height="600" title="null" id="oLeftPaneContent" src="campaign_sp_selection" frameBorder="0" scrolling="no" style="HEIGHT: 690px; WIDTH: 205px; DISPLAY: block; VISIBILITY: visible" onload="this.title=oLeftPaneContent.document.title;"&gt;
                                  &lt;html&gt;
                                      &lt;head&gt;...&lt;/head&gt;
                                      &lt;body tabIndex="-1" scroll="no" style="MARGIN:0px; BACKGROUND-COLOR: #f4f4f4" onkeydown="return onBodyKeyDown(event)" onekeypress="return onBodyKeyPress(event)" onclick="onBodyClick(event)" onload="main();" onunload="handleUnload(window); if (top.selectionMediator) top.selectionMediator = null;" onresize="null"&gt;
                                          &lt;form&gt;...&lt;/form&gt;
                                          &lt;iframe&gt;...&lt;/iframe&gt;
                                          &lt;form name="oFormMain" id="oFormMain" onsubmit="return false" action="campaign_sp_selection" encType="application/x-www-form-urlencoded" method="post"&gt;
                                              &lt;div&gt;...&lt;/div&gt;
                                              &lt;div tabindex="0" id="workPaneWrapper" role="region" accessKey="s" style="WIDTH: 100%" aria-label="Selector"&gt;
                                                  &lt;table&gt;...&lt;/table&gt;
                                                  &lt;div id="workContentWrapper" style="BORDER-TOP: #7386ad 1px solid; BORDER-RIGHT: #7386ad 1px solid; WIDTH: 100%; BORDER-BOTTOM: #7386ad 1px solid; BORDER-LEFT: #7386ad 1px solid; BACKGROUND-COLOR: #e6edf6"&gt;
                                                      &lt;div id="workAreaWrapper" style="WIDTH: 100%; BORDER-BOTTOM: white 1px solid"&gt;
                                                          &lt;table&gt;...&lt;/table&gt;
                                                          &lt;div class="listContainer" id="campaignSPTreeWrapper" style="OVERFLOW: auto; HEIGHT: 574px; WIDTH: 100%"&gt;
                                                              &lt;table width="" id="" border="" cellSpacing="" cellPadding=""&gt;
                                                                  &lt;tbody&gt;
                                                                      &lt;tr id="" onclick="" ondbclick="" uid="" notMultiSelectable="true" selectable="true" isopen="false" isnode="true"&gt;
                                                                          &lt;td class="tableItem" id="r0c0" noWrap="nowrap" style="PADDING-LEFT: 7px" rowSpan="1" colspan="1" iscell="true"&gt;
                                                                              &lt;img class="treeNorgie" id="campaignSPTreer0Norg" onclick="campaignSPTree.onToggle('r0')" ondbclick="campaignSPTree.onToggleBranch('r0')" alt="Fermé(e)" src="/wfo/uif/images/norgie_deselected.gif?v=11.1.1.7673" border="0" /&gt;
                                                                              &lt;a onkeydown="campaignSPTree.onKeyDown(this);" onclick="return false;" href="#r0" shape=""&gt;
                                                                                  &lt;span&gt;
                                                                                      &lt;label class="hidden-label"&gt;Tree level 0,1 of 3.&lt;/label&gt;
                                                                                      &lt;span id="r0c0Content" name="r0c0Content"&gt;
                                                                                          &lt;img alt="" src="/wfo/bbm/images/icons/campaign.gif?v=11.1.1.7673" border="0" /&gt;SCO CE HMO N2
                                                                                      &lt;/span&gt;
                                                                                      &lt;label class="hidden-label" id="campaignSPTreer0ChildInfo" childInfo=", node has 98 items. Press the right arrow key to show/hide this row's child items."&gt;.Ouvert(e), node has 98 items. Press the right arrow key to show/hide this row's child items.&lt;/label&gt;
                                                                                  &lt;/span&gt;
                                                                              &lt;/a&gt;
                                                                          &lt;/td&gt;
                                                                      &lt;/tr&gt;
                                                                  &lt;/tbody&gt;
                                                              &lt;/table&gt;
                                                          &lt;/div&gt;
                                                      &lt;/div&gt;
                                                      &lt;div&gt;...&lt;/div&gt;
                                                  &lt;/div&gt;
                                              &lt;/div&gt;                                               
                                          &lt;/form&gt;
                                      &lt;/body&gt;
                                  &lt;/html&gt;
                              &lt;/iframe&gt;
                          &lt;/td&gt;
                          &lt;td&gt;...&lt;/td&gt;
                          &lt;td&gt;...&lt;/td&gt;
                          &lt;td&gt;...&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
          &lt;/div&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I wrote these few lines in Python of code yet simple:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.ie.options import Options
  from selenium.webdriver.common.action_chains import ActionChains
  import time
  
  ie_options = Options()
  ie_options.ignore_protected_mode_settings = True
  ie_options.ensure_clean_session = True
  
  browser = webdriver.Ie(options=ie_options)
  browser.implicitly_wait(10)
  action = ActionChains(browser)
  
  browser.get('http://xxxxxxxxx')
  # Auto authentification
  browser.find_element_by_id("spanLinkActiver").click()
  
  #Click on tab "Forecasting and Scheduling"
  browser.find_element_by_xpath("//a[contains(text(),'Forecasting and Scheduling')]").click()
  browser.find_element_by_id("workPaneWrapper")
  browser.find_element_by_id("workContentWrapper")
  
  time.sleep(10)
  
  browser.close()
  </code></pre>
  
  <p>At runtime I have the following error while the previous id "workPaneWrapper" is correctly found:</p>
  
  <pre><code>Traceback (most recent call last):
    File ".\ConnectToOpoci.py", line 26, in &lt;module&gt;
      browser.find_element_by_id('workContentWrapper')
    File "C:\Applications\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 360, in find_element_by_id
      return self.find_element(by=By.ID, value=id_)
    File "C:\Applications\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
      return self.execute(Command.FIND_ELEMENT, {
    File "C:\Applications\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
      self.error_handler.check_response(response)
    File "C:\Applications\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
      raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.NoSuchElementException: Message: Unable to find element with css selector == [id="workContentWrapper"]
  </code></pre>
  
  <p>Could you please help me understand why it doesn't work ?</p>
  
  <p>Thank you in advance for your help</p>