title: Retrieving Text between <span>Text</span> in Selenium C#
body: <p>I am facing problem in retrieving Subject title of a mail from Unread mails using Selenium webdriver-C#.</p>
  
  <p>Here's the HTML code :</p>
  
  <pre><code>&lt;div class="ae4 UI UJ" gh="tl"&gt;
   &lt;div class="Cp"&gt;
    &lt;div&gt;
      &lt;table id=":8e" class="F cf zt" cellpadding="0"&gt;
      &lt;colgroup&gt;
      &lt;tbody&gt;
        &lt;tr id=":8d" class="zA zE"&gt;
         &lt;td class="PF xY"&gt;&lt;/td&gt;
         &lt;td id=":8c" class="oZ-x3 xY" style=""&gt;
         &lt;td class="apU xY"&gt;
         &lt;td class="WA xY"&gt;
         &lt;td class="yX xY "&gt;
         &lt;td id=":87" class="xY " role="link" tabindex="0"&gt;
          &lt;div class="xS"&gt;
           &lt;div class="xT"&gt;
            &lt;div id=":86" class="yi"&gt;
            &lt;div class="y6"&gt;
            **&lt;span id=":85"&gt;
               &lt;b&gt;hi&lt;/b&gt;
              &lt;/span&gt;**
              &lt;span class="y2"&gt;
            &lt;/div&gt;
           &lt;/div&gt;
          &lt;/div&gt;
         &lt;/td&gt;
         &lt;td class="yf xY "&gt; &lt;/td&gt;
         &lt;td class="xW xY "&gt;
       &lt;/tr&gt;
  </code></pre>
  
  <p>I am able to print 'emailSenderName' in console but unable to print 'text' (subject line i.e. "hi" in this case) as it is between span tags. Here's my code.</p>
  
  <pre><code> //Try to Retrieve mail Senders name and Subject
          IWebElement tbl_UM = d1.FindElement(By.ClassName("Cp")).FindElement(By.ClassName("F"));
          IList&lt;IWebElement&gt; tr_ListUM = tbl_UM.FindElements(By.ClassName("zE"));
          Console.WriteLine("NUMBER OF ROWS IN THIS TABLE = " + tr_ListUM.Count());
          foreach (IWebElement trElement in tr_ListUM)
          {
              IList&lt;IWebElement&gt; td_ListUM = trElement.FindElements(By.TagName("td"));
              Console.WriteLine("NUMBER OF COLUMNS=" + td_ListUM.Count());
              string emailSenderName = td_ListUM[4].FindElement(By.ClassName("yW")).FindElement(By.ClassName("zF")).GetAttribute("name");
              Console.WriteLine(emailSenderName);
              string text = td_ListUM[5].FindElement(By.ClassName("y6")).FindElement(By.TagName("span")).FindElement(By.TagName("b")).Text;
              Console.WriteLine(text);
          }
  </code></pre>
  
  <p>I had also tried by directly selecting the Text from  tag of 5th Column (td), which contains the subject text (in my case), but no results.</p>
  
  <p>I might went wrong somewhere or may be there is some other way of doing it.</p>
  
  <p>Please suggest, Thanks in advance :)</p>