title: python selenium scrape the whole table
body: <p>The purpose of this code is to scrape a data table form a some links then turn it into a pandas data frame.</p>
  
  <p>The problem is that this code only scrapes the first 7 rows only which are in the first page of the table and I want to capture the whole table.
  so when i tried to loop over table pages, i got an error.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>from selenium import webdriver
  
  urls = open(r"C:\Users\Sayed\Desktop\script\sample.txt").readlines()
  for url in urls:
      driver = webdriver.Chrome(r"D:\Projects\Tutorial\Driver\chromedriver.exe")
      driver.get(url)
      for item in driver.find_element_by_xpath('//*[contains(@id,"showMoreHistory")]/a'):
          driver.execute_script("arguments[0].click();", item)
  
      for table in driver.find_elements_by_xpath('//*[contains(@id,"eventHistoryTable")]//tr'):
          data = [item.text for item in table.find_elements_by_xpath(".//*[self::td or self::th]")]
          print(data)
  </code></pre>
  
  <p>here is the error:</p>
  
  <p>Traceback (most recent call last):</p>
  
  <p>File "D:/Projects/Tutorial/ff.py", line 8, in 
      for item in driver.find_element_by_xpath('//*[contains(@id,"showMoreHistory")]/a'):</p>
  
  <p>TypeError: 'WebElement' object is not iterable</p>