HTML的结构如下:
<section class="AutoTest">
<a title="xpath" href="#"></a>
<div style="#">
webdriver ui auto Test !
</div>
</section>
我们首先需要获取title=”xpath”的节点,
Xpath写法为
driver.findElements(By.xpath("//a[@title='xpath']"))
然后我们在获取他的父节点
driver.findElements(By.xpath("//a[@title='xpath']/parent::section"))
我们在查找子节点div下的文本内容,
driver.findElements(By.xpath("//a[@title='xpath']/parent::section/div/text()"))
通过以上我们可以查找的相关的节点