【发布时间】:2020-06-07 23:43:29
【问题描述】:
我有以下 DOM 结构/HTML:
<div class = "something" >
<div>
<span>Some text</span>
</div>
"Automated Script"
</div>
我正在使用 Selenium Webdriver 进行测试,并且必须获取字符串自动脚本来执行断言。
Assert.assertEquals("Automated Script",webDriver.findElement(By.xpath("/div")).getText());
但是上面的 xpath 会同时获取一些文本和自动脚本。 有没有办法只获取字符串自动脚本?
【问题讨论】:
-
最初 Assert 中的预期值是一个字符串变量,所以我已经像在 UI 中一样获取字符串。
标签: html selenium-webdriver dom xpath assert