[英]How to print text from child node using xpath?
xpath: 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。
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: HTML:
12.6 caught Hughes 73/4 12.6抓住休斯73/4
this should work : 这应该工作:
WebElement txt= driver.findElement(By.xpath("//*[@id='full-scorecard']/div[2]/div/table[1]/tbody/tr[3]/td[2]"));
System.out.println(txt.getText());
Selenium webdriver return all test under element object including child element. Selenium Webdriver返回所有包含子元素的对象下的测试。
So after reading you should remove integer values from text. 因此,阅读后应从文本中删除整数值。
Thanks Sadik 谢谢萨迪克
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.