好的,我已经找到了使用Xpath和后续兄弟的解决方案,它并不太复杂。
final WebElement errorElement = web.findElement(By.xpath("//*[@id='" + elementId + "']/following-sibling::span[@]"));这给了我我想要的东西,并
NoSuchElementException在不在这里时抛出了一个,这正是我想要的。

好的,我已经找到了使用Xpath和后续兄弟的解决方案,它并不太复杂。
final WebElement errorElement = web.findElement(By.xpath("//*[@id='" + elementId + "']/following-sibling::span[@]"));这给了我我想要的东西,并
NoSuchElementException在不在这里时抛出了一个,这正是我想要的。