title: How to retrieve the text from a text node within an element through Xpath, C# and Selenium
body: <p>I am a test automation engineer who is Working in selenium for the last few years This is my first post in Stackoverflow. </p>
  
  <p>I am trying to fetch the text from an element, but the selenium is not even identifying the element. I am using the specflow setup in visual studio and c# as the language.</p>
  
  <p>Below is the sample html code (This is just a sample structure of the HTML code, not the original one) :</p>
  
  <pre><code>&lt;p class="day"&gt;
   &lt;meta atts="somevalue"&gt;
   &lt;span&gt;Some text&lt;/span&gt;
   &lt;meta atts="somevalue"&gt;
   &lt;meta atts="somevalue"&gt;
   "Active"
  &lt;/p&gt;
  </code></pre>
  
  <p>I want to fetch the text <strong>Active</strong> from the above HTML. </p>
  
  <p>I wrote multiple xpaths for this, when i check this in chrome the xpaths are correct and it is highlighting the element</p>
  
  <p>Xpaths trials :</p>
  
  <pre><code>1. //p[@class='day']/text()
  2. //p[@class=''day]/meta[@atts='somevalue'][3]/following-sibling::text()
  3. few more..
  </code></pre>
  
  <p>for all the xpaths <code>text()</code> comes in between or at the end. all these are correct and unique when i manually checked it.</p>
  
  <p>there are no frames involved in the web page i am automating. there is no page loading issue also. i have tried with with different wait statements. also tried giving a long thread.sleep().</p>
  
  <p>the location of the element is always same. only the value in it will get changed. ie, the xpath for this element is not dynamic.</p>
  
  <p>I am getting the error in below line. (driver is initialized properly, it is working for everything else)</p>
  
  <pre><code>String StatusVal = driver.FindElement(By.XPath("(//meta[@itemprop='closes'])[1]/following-sibling::text()")).Text;
  </code></pre>
  
  <p>whatever i try i am getting the below error saying element is not found,</p>
  
  <pre><code>OpenQA.Selenium.NoSuchElementException: Could not find element by: By.XPath: (//meta[@itemprop='closes'])[1]/following-sibling::text()
  </code></pre>
  
  <p>The above is actual xpath, if i manually check the xpath once the test is failed in the same browser it is available there and it is unique.</p>
  
  <p>ie, in my analysis my xpath is correct, there are no frames involved , there is no wait issue in the page as i am performing actions to the near by elements successfully and i am giving more than enough time for the page to load. all the normal selenium setups are done in my system and everything is working fine other than this one.</p>
  
  <p>Selenium version: 3.12.0</p>