title: Webscraping a Javascript React page using Python Selenium on an element that hides after few seconds
body: <p>I'm trying to scrape a webpage that has a React element that hides the dropdown after few seconds. </p>
  
  <p>This is what you see when you first get to the page and the tab I would like to scrape. </p>
  
  <p><a href="https://i.stack.imgur.com/VVY4r.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VVY4r.jpg" alt="Dropdown element I want to scrape. Specifically the &#39;24&#39; people are viewing this event line."></a></p>
  
  <p>I'm trying to scrape the part that says <strong>Don't miss out! 24 people are viewing this event</strong></p>
  
  <p>After few seconds, the tab disappears and gets replaced by another dropdown element that says <strong>Get notified at the right price!</strong></p>
  
  <p><a href="https://i.stack.imgur.com/V1Q5P.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V1Q5P.jpg" alt="new dropdown that replaces the one i want to scrape. It hides the previous dropdown"></a></p>
  
  <p>The source code reveals the <strong>view count</strong> drop down as being hidden after few seconds. The top of the code shows the new dropdown while the bottom with the <strong>'hide'</strong> in the div class being the dropdown I want to scrape. </p>
  
  <p><a href="https://i.stack.imgur.com/2A3fx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2A3fx.jpg" alt="The source code showing the hidden dropdown code"></a></p>
  
  <p>I've tried getting the <strong>div class = "urgency-component-container</strong> but due to it being hidden, it returns nothing. I've also tried getting the <strong>div class = "dropdown-header-item"</strong> but that was returning nothing as well. </p>
  
  <p>I've tried getting the XPath to the dropdown-header-item (//*[@id="dropdown-header"]/div/div<a href="https://i.stack.imgur.com/VVY4r.jpg" rel="nofollow noreferrer">1</a>) but that didn't work either. </p>
  
  <p>How can I scrape the dropdown that "hides" after few seconds? Thanks</p>
  
  <p>EDIT:</p>
  
  <p>the website url is :
  <a href="https://www.stubhub.com/anaheim-ducks-tickets-anaheim-ducks-anaheim-honda-center-11-14-2019/event/104217448/?sort=price%20asc" rel="nofollow noreferrer">https://www.stubhub.com/anaheim-ducks-tickets-anaheim-ducks-anaheim-honda-center-11-14-2019/event/104217448/?sort=price%20asc</a></p>
  
  <p>The code I used was</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  import time
  
  driver = webdriver.Chrome()
  url = 'https://www.stubhub.com/anaheim-ducks-tickets-anaheim-ducks-anaheim-honda-center-11-14-2019/event/104217448/?sort=price+asc'
  driver.get(url)
  
  content = driver.find_element_by_class_name('dropdown-header-item')
  </code></pre>
  
  <p>If I execute the code straightaway I get an error </p>
  
  <pre><code>NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".dropdown-header-item"}
  </code></pre>
  
  <p>but if I wait few seconds and run it then I get </p>
  
  <pre><code>Get notified at the right price!Set price alert
  </code></pre>