title: Selenium Python not locating element
body: <p>I have a Selenium python code that I am running on an internal Dynamic CRM website to download data.
  For the most part the code works until the last step where it does not locate the element &quot;Export Data&quot;. Export Data comes up in a new ribbon on the toolbar triggered by our previous step. Below is the code and HTML.
  Also attached the HTML portion of the Export. What am I doing wrong?
  Please help and let me know if you need more information</p>
  <p>Screen 1 CRM shows the Results button when clicked takes us to Screen 2 that is a new tab on the toolbar:
  <a href="https://i.stack.imgur.com/3EE3t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3EE3t.png" alt="related image" /></a>
  Screen 2 with the new tab on toolbar
  <a href="https://i.stack.imgur.com/5gVb9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5gVb9.png" alt="related image" /></a>
  HTML code of Export
  <a href="https://i.stack.imgur.com/2RzXD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2RzXD.png" alt="related image" /></a></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.action_chains import ActionChains
  from selenium.webdriver.chrome.options import Options
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support.ui import Select
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support import expected_conditions as EC
  import time
  from bs4 import BeautifulSoup
  import requests
  import pandas as pd
  import os
  from pathlib import Path
  import shutil
  
  
  #--| Chrome Setup
  options = webdriver.ChromeOptions()
  # options.add_argument("--headless")
  options.add_argument('--disable-gpu')
  options.add_argument('--log-level=3')
  prefs={"download.default_directory":r"
  
  
  #Setup Chrome preferences
  options.add_experimental_option("prefs",prefs)
  browser = webdriver.Chrome(chrome_options=options)
  
  #Direct Link to NGL Five year Forecast Data Only
  browser.get('&lt;URL&gt;')
  browser.maximize_window()
  
  # Store current window position
  window_before = browser.window_handles[0]
  
  wait = WebDriverWait(browser, 30)
  
  #Key in Email
  web_loginscreen = wait.until(EC.element_to_be_clickable((By.ID, 'i0116')))  
  web_loginscreen.send_keys("&lt;UserName&gt;")
  
  # Next Button
  web_loginbutton = browser.find_element_by_xpath('//*[@id="idSIButton9"]')
  web_loginbutton.click()
  
  window_before_title = browser.title
  print(window_before_title)
  #Filter button 
  web_filter = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="advancedFindLauncher"]/button/span/span')))  
  web_filter.click()
  
  #browse to newly opened download window
  browser.switch_to.window(browser.window_handles[1])
  window_after = browser.window_handles[1]
  window_after_title = browser.title
  print(window_after_title)
  
  
  # Select Agreements
  time.sleep(5)
  
  # locate all elements
   
  frame = browser.find_element_by_xpath('//*[@id="contentIFrame0"]')
  browser.switch_to.frame(frame)
  # 
  
  dropdown = browser.find_element_by_xpath('//*[@id="slctPrimaryEntity"]')
  dropdown.click()
  
  agreements = browser.find_element_by_xpath('//*[@id="slctPrimaryEntity"]/option[35]')
  agreements.click()
  # print(dropdown.text)
  
  # Go back out of iframe to default content
  browser.switch_to.default_content()
  # Look For Results
  web_results = browser.find_element_by_xpath('//*[@id="apttusps.ApplicationRibbon.{!EntityLogicalName}.Button2.Button-Large"]') 
  web_results.click()
  
  # ribbonframe = browser.find_element_by_id('apttus_apts_agreement|NoRelationship|SubGridStandard|Mscrm.SubGrid.apttus_apts_agreement.MainTab.ExportData')
  
  # # browser.find_element_by_class_name('ms-cui-tabContainer ms-cui-tabContainer-lb')
  # ribbonframe.click()
  
  # browser.switch_to.frame(ribbonframe)
  
  # Export to Excel
  web_results_excel = browser.find_element_by_xpath('//*[@id="apttus_apts_agreement|NoRelationship|SubGridStandard|Mscrm.SubGrid.apttus_apts_agreement.ExportToExcel-Large"]')
  # find_element_by_xpath('//*[@id="apttus_apts_agreement|NoRelationship|SubGridStandard|Mscrm.SubGrid.apttus_apts_agreement.ExportToExcel-Large"]')
  web_results_excel.click()
  
  time.sleep(15) #seconds
  browser.close()
  browser.quit()</code></pre>
  </div>
  </div>
  </p>