title: Extracting link text from HTML Table in python selenium
body: <p>I'm new to selenium. I wanted to extract the link text from the HTML table from the following HTML code of the website.</p>
  
  <p>Code Snippet:</p>
  
  <pre><code>&lt;div style="width:210px" id="calenderdiv"&gt;
      &lt;table id="calender" align="center" bgcolor="#ABABAB" width="90%" cellspacing="1" cellpadding="0" border="0"&gt;
      &lt;tbody&gt;
          &lt;tr height="25" bgcolor="#DDDDDD" style="font-family:arial ;font-size:12;font-weight:bold; color: #006699"&gt;
              &lt;td align="center" width="14%"&gt;S&lt;/td&gt;
              &lt;td align="center" width="14%"&gt;M&lt;/td&gt;
              &lt;td align="center" width="14%"&gt;T&lt;/td&gt;
              &lt;td align="center" width="14%"&gt;W&lt;/td&gt;
              &lt;td align="center" width="14%"&gt;T&lt;/td&gt;
              &lt;td align="center" width="14%"&gt;F&lt;/td&gt;
              &lt;td align="center" width="14%"&gt;S&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr height="25" bgcolor="#FFFFFF" style="font-family:arial ;font-size:12;font-weight:bold; color: #006699"&gt;
              &lt;td bgcolor="#EFEFEF" align="center"&gt;&lt;a href="/2010/1/1/archivelist/year-2010,month-1,starttime-40179.cms"&gt;&lt;/a&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/1/archivelist/year-2010,month-1,starttime-40179.cms"&gt;&lt;/a&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/1/archivelist/year-2010,month-1,starttime-40179.cms"&gt;&lt;/a&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/1/archivelist/year-2010,month-1,starttime-40179.cms"&gt;&lt;/a&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/1/archivelist/year-2010,month-1,starttime-40179.cms"&gt;&lt;/a&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/1/archivelist/year-2010,month-1,starttime-40179.cms"&gt;1&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/2/archivelist/year-2010,month-1,starttime-40180.cms"&gt;2&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr height="25" bgcolor="#FFFFFF" style="font-family:arial ;font-size:12;font-weight:bold; color: #006699"&gt;
              &lt;td bgcolor="#EFEFEF" align="center"&gt;&lt;a href="/2010/1/3/archivelist/year-2010,month-1,starttime-40181.cms"&gt;3&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/4/archivelist/year-2010,month-1,starttime-40182.cms"&gt;4&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/5/archivelist/year-2010,month-1,starttime-40183.cms"&gt;5&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/6/archivelist/year-2010,month-1,starttime-40184.cms"&gt;6&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/7/archivelist/year-2010,month-1,starttime-40185.cms"&gt;7&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/8/archivelist/year-2010,month-1,starttime-40186.cms"&gt;8&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/9/archivelist/year-2010,month-1,starttime-40187.cms"&gt;9&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr height="25" bgcolor="#FFFFFF" style="font-family:arial ;font-size:12;font-weight:bold; color: #006699"&gt;
              &lt;td bgcolor="#EFEFEF" align="center"&gt;&lt;a href="/2010/1/10/archivelist/year-2010,month-1,starttime-40188.cms"&gt;10&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/11/archivelist/year-2010,month-1,starttime-40189.cms"&gt;11&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/12/archivelist/year-2010,month-1,starttime-40190.cms"&gt;12&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/13/archivelist/year-2010,month-1,starttime-40191.cms"&gt;13&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/14/archivelist/year-2010,month-1,starttime-40192.cms"&gt;14&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/15/archivelist/year-2010,month-1,starttime-40193.cms"&gt;15&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/16/archivelist/year-2010,month-1,starttime-40194.cms"&gt;16&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr height="25" bgcolor="#FFFFFF" style="font-family:arial ;font-size:12;font-weight:bold; color: #006699"&gt;
              &lt;td bgcolor="#EFEFEF" align="center"&gt;&lt;a href="/2010/1/17/archivelist/year-2010,month-1,starttime-40195.cms"&gt;17&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/18/archivelist/year-2010,month-1,starttime-40196.cms"&gt;18&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/19/archivelist/year-2010,month-1,starttime-40197.cms"&gt;19&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/20/archivelist/year-2010,month-1,starttime-40198.cms"&gt;20&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/21/archivelist/year-2010,month-1,starttime-40199.cms"&gt;21&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/22/archivelist/year-2010,month-1,starttime-40200.cms"&gt;22&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/23/archivelist/year-2010,month-1,starttime-40201.cms"&gt;23&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr height="25" bgcolor="#FFFFFF" style="font-family:arial ;font-size:12;font-weight:bold; color: #006699"&gt;
              &lt;td bgcolor="#EFEFEF" align="center"&gt;&lt;a href="/2010/1/24/archivelist/year-2010,month-1,starttime-40202.cms"&gt;24&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/25/archivelist/year-2010,month-1,starttime-40203.cms"&gt;25&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/26/archivelist/year-2010,month-1,starttime-40204.cms"&gt;26&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/27/archivelist/year-2010,month-1,starttime-40205.cms"&gt;27&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/28/archivelist/year-2010,month-1,starttime-40206.cms"&gt;28&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/29/archivelist/year-2010,month-1,starttime-40207.cms"&gt;29&lt;/a&gt;&lt;/td&gt;
              &lt;td align="center"&gt;&lt;a href="/2010/1/30/archivelist/year-2010,month-1,starttime-40208.cms"&gt;30&lt;/a&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr height="25" bgcolor="#FFFFFF" style="font-family:arial ;font-size:12;font-weight:bold; color: #006699"&gt;
              &lt;td bgcolor="#EFEFEF" align="center"&gt;&lt;a href="/2010/1/31/archivelist/year-2010,month-1,starttime-40209.cms"&gt;31&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td&gt;&amp;nbsp; &lt;/td&gt;
              &lt;td&gt;&amp;nbsp; &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p></p>
  
  <p>For the above snippet I wrote the following code in selenium:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.by import By
  
  option = webdriver.ChromeOptions()
  option.add_argument("--incognito")
  option.add_argument("--start-maximized")
  
  chrome_path = r"C:\Users\singh\Downloads\chromedriver_win32\chromedriver.exe"
  browser = webdriver.Chrome(chrome_path, options=option)
  browser.get("https://timesofindia.indiatimes.com/archive/year-2010,month-1.cms")
  browser.implicitly_wait(10)
  
  num = []
  numbers = browser.find_elements(By.XPATH, "//table[@class = 'calender']/tbody/tr/td/a[@href]")
  
  for n in numbers:
      number = n.text
      num.append(number)
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>num = ['S', 'M', 'T', 'W', 'T', 'F', 'S', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
  </code></pre>
  
  <p>The program is returning both <em>num</em> and <em>numbers</em> lists as empty lists.</p>
  
  <p>I know something's not correct in the XPath entered in the code. But I'm not able to figure out what is the error.</p>
  
  <p>OS: <em>Windows 10 x64</em><br>
  Python IDE: <em>Anaconda Spyder</em><br>
  Python Version: <em>3.6</em>  </p>