How to extract text from child Text Nodes - Selenium How to extract text from child Text Nodes - Selenium selenium selenium

How to extract text from child Text Nodes - Selenium


To extract the text I give you €0.00. you can use the following line of code :

IWebElement elem = driver.FindElement(By.XPath("//div[@class='windowClass' and @id='windowID']"));string text = (string)((IJavaScriptExecutor)driver).ExecuteScript("return arguments[0].childNodes[3].textContent;", elem);


Here I get all the text and split the text by <br> and we can print the text by separating.

 String mytext=driver.findElement(By.xpath("//div[@id='windowID'].getAttribute("innerHTML");    String[] separatestring= mytext.split(Pattern.quote("<br>"));    String firstone= separatestring[0];    String secondtone= separatestring[1];    System.out.println(firstone);    System.out.println(secondtone);

I did it by java, Here you can convert it to C#. Hope it will help you.