title: Closing a generic pop up in Selenium
body: <p>While scraping a page using selenium webdriver, there is a "pop up" that appears .</p>
  
  <p>On Opening the page, <a href="http://www.fanatics.com/search/red%20shoes" rel="noreferrer">http://www.fanatics.com/search/red%20shoes</a> - I see a popup window with xpath '//*[@id="mm_DesktopInterstitialImage"]' - but I don't want to be using the xpath to close this alert, and have something genric that can dismiss/close the alert. 
  Here's what I tried so far -:</p>
  
  <pre><code>from selenium import webdriver
  import os
  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  
  chromedriver = "/usr/local/CHROMEDRIVER"
  desired_capabilities=DesiredCapabilities.CHROME
  os.environ["webdriver.chrome.driver"] = chromedriver
  driver = webdriver.Chrome(chromedriver,desired_capabilities=desired_capabilities)
  url='http://www.fanatics.com/search/red%20shoes'
  driver.get(url)
  #driver.set_page_load_timeout(300)
  driver.implicitly_wait(60)
  alert = driver.switch_to_alert()
  alert.dismiss
  handle=driver.window_handles
  print handle
  #[u'CDwindow-B1E9C127-719D-ACAA-19DE-1A6FA265A4FF']
  </code></pre>
  
  <p>From what I understand from related examples, folks usually switch window handles, but my handle has a single element.i.e, <code>driver.switch_to_window(driver.window_handles[1])</code> then <code>driver.close()</code> and finally shift again, using <code>driver.switch_to_window(driver.window_handles[1])</code>  I also used implicit wait, since I was not sure, if the alert window was being read at-all - but that did not work either. I do not wnat to hard-code for the xpath,if that is possible.</p>
  
  <p><strong>What am I doing wrong ?</strong></p>
  
  <p>Related, but does't work for me : <a href="https://stackoverflow.com/questions/21962635/selenium-python-how-to-close-a-pop-up-window">Selenium python how to close a pop up window?</a></p>