根据JavaDocs,您可以执行以下操作:
WebElement input = divA.findElement(By.xpath(".//input"));如何在xpath中询问“包含带有文本’hello world’的跨度的div标签”?
WebElement elem = driver.findElement(By.xpath("//div[span[text()='hello world']]"));XPath规范对此非常好阅读。

根据JavaDocs,您可以执行以下操作:
WebElement input = divA.findElement(By.xpath(".//input"));如何在xpath中询问“包含带有文本’hello world’的跨度的div标签”?
WebElement elem = driver.findElement(By.xpath("//div[span[text()='hello world']]"));XPath规范对此非常好阅读。