0
所以我要解析HTML,其構造爲這樣只得到即時的文本進行HTML與webdriver的硒2.22
<div>
Hello
<div name="DONOTWANT">
Text that I dont want and other junk
</div>
World
</div>
我需要將檢索HTML塊即時文本的解決方案。在這個例子中,我想要「Hello World」,而忽略所有其他文本。有什麼建議,我怎麼可以做到這一點與webdriver和硒?我用java編程,但如果你有另一種可以翻譯的語言的解決方案,我也會這樣做。
目前,如果我有像
String foo = driver.findElement(By.xpath(".//div")).getText();
富將包含「文本Hello,我不想和其他垃圾的世界」,這是不是最佳的。
也許這個問題ca help you: http://stackoverflow.com/questions/4735453/xpath-xquery-find-text-in-a-node-but-ignoring-content-of-specific-descendant – VolkerK