Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用webdriver和selenium 2.22仅获取即时文本输出html_Java_Xpath_Selenium_Webdriver - Fatal编程技术网

Java 使用webdriver和selenium 2.22仅获取即时文本输出html

Java 使用webdriver和selenium 2.22仅获取即时文本输出html,java,xpath,selenium,webdriver,Java,Xpath,Selenium,Webdriver,因此,我必须解析这样构造的HTML <div> Hello <div name="DONOTWANT"> Text that I dont want and other junk </div> World </div> foo将包含“Hello Text that I don't want and other junk World”(我不想要的Hello Text and other junk Wo

因此,我必须解析这样构造的HTML

<div>
    Hello
    <div name="DONOTWANT">
        Text that I dont want and other junk
    </div>
    World
</div>

foo将包含“Hello Text that I don't want and other junk World”(我不想要的Hello Text and other junk World),这不是最理想的。我以前遇到过类似的问题,我必须在JavascriptExecutor的帮助下使用java脚本来解决它

你可以在这个网站上查看我以前问过的这个问题-


让我知道这是否解决了您的问题。

也许这个问题可以帮助您:
String foo = driver.findElement(By.xpath(".//div")).getText();