title: Use Selenium to click a 'Load More' button until it doesn't exist (Youtube)
body: <p>I am trying to write a python script that goes to a youtube channel. Clicks on the Video Tab. Then Scrapes the webpage for content. I am all fine for scraping the content, until... I get to the load more button. The python script I have manages to click the load more button once but it never presses it again :'( How can I modify the code I have to make it click it again and again until it doesn't exist. That way, I can open up the user's complete channel and get information from every video they have. Thankyou.</p>
  
  <pre><code>from selenium import webdriver      
  from selenium.common.exceptions import NoSuchElementException
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  </code></pre>
  
  <p>^^ Those are the modules that I have imported. I don't know how to add in the NoSuchElementException into my code either. Here is the code:</p>
  
  <pre><code>chrome_path = r"/Users/jack/Desktop/Other/Downloads/Software_and_Programs/chromedriver"
  browser = webdriver.Chrome(chrome_path)
  YOUTUBER_HOME_PAGE_URL = "https://www.youtube.com/user/Google/videos"
  PATIENCE_TIME = 60
  LOAD_MORE_BUTTON_XPATH = '//*[@id="browse-itemsprimary"]/li[2]/button/span/span[2]' 
  
  def waitForLoad(inputXPath):
      Wait = WebDriverWait(browser, PATIENCE_TIME)
      Wait.until(EC.presence_of_element_located((By.XPATH, inputXPath)))
  
  loadMoreButtonExists = True
  while loadMoreButtonExists:
      try:
          waitForLoad(LOAD_MORE_BUTTON_XPATH)
          WebDriverWait(browser, PATIENCE_TIME)
          loadMoreButton = browser.find_element_by_partial_link_text('Load More')
          #loadMoreButton = browser.find_element_by_xpath(LOAD_MORE_BUTTON_XPATH)
          loadMoreButton.click()
      except:
          print 'we have completely loaded every video from this Youtuber. Now we will scrape the video content\n'
          loadMoreButtonExists = False
  </code></pre>
  
  <p>I have used the xpath way and that still seems not to work. I have that commented out in the code above. It would be so awesome if I could get help on this. I haven't been able to find any good answers. I believe it can be done with selenium, but if not what should I use?</p>