xpath:
//*[@id='full-scorecard']/div[2]/div/table[1]/tbody/tr[3]/td[2]/child::text()
The above code only returns a webelement am not able to print the text.
WebElement txt= driver.findElement(By.xpath(
"//*[@id='full-scorecard']/div[2]/div/table[1]/tbody/tr[3]/td[2]/child::text()"));
System.out.println(txt);
HTML:
12.6
caught Hughes
73/4
By.xpath()locator has to point to a web element. You cannot match a text node this way.getText()on the WebElement like suggested in here//a[contains(@href,'#id1')]/@class), so apparently "web elements" are not always DOM elements. Unfortunately Selenium's documentation is not very systematic or thorough.