When i tried using the below code…the td tag is returned and not the value of the td tag.
List<?> byXPath = page2.getByXPath("//tr[@class='metadata odd']/td");
System.out.println(byXPath.get(0).toString());
For ex:If the tag is
<td class='metadata odd'>Arun</td>
The result was
<td class='metadata odd'>
…. I need the result to be Arun. Kindly help
What you’re looking for is actually the string representation of the text child node of the
tdtag, not the string representation of thetdelement itself, which you are requesting at the moment.Use a slightly different XPath expression to reference the text child node directly, like this:
See also this question.