擅长:python、mysql、java
<p>Selenium只评估web元素。函数的作用是:返回一个对象。解决方案是在javascript函数中执行xpath并将其值返回到变量中。例如,对于python:</p>
<pre><code>returnText = []
returnText = driver.execute_script("return document.evaluate(\"//span[@class='tableNode']/text()[preceding-sibling::br and following-sibling::br]\", document, null, XPathResult.STRING_TYPE, null).stringValue;")
for item in returnText:
print item
</code></pre>