How to fetch text for

<h1 _ngcontent-gtj-c13=""> Site-2 
<span _ngcontent-gtj-c13="" class="seprator">|</span> 
Building-1 <!----> </h1>

I have used attribute innerhtml,value,outerhtml,javascript Not able to fetch site name with building name

getting text= Site-2 |
expected =  Site-2 | Building-1
  • 1
    <h1 _ngcontent-gtj-c13=""> Site-2 <span _ngcontent-gtj-c13="" class="seprator">|</span> Building-1 <!----> </h1> – priyanka Sep 20 '19 at 9:22

Assuming that class attribute value-seprator for span is unique for the page.

First find the parent element of the "span class="seprator" which is h1

IWebElement option = driver.FindElement(By.XPath("//span[@class='seprator']//parent::h1"));

Now get the innertext of the h1 element using the code.

var textinside = option.Text;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.