问题描述
我尝试在页面上查找文本 driver.findElement(By.xpath("//label[contains(text(),'Some text')]"));
为什么系统不显示关于 NoSuchElementException 的错误
解决方法
您不会像不点击driver.findElement(By.xpath("//label[contains(text(),'Some text')]"));
或其他东西那样使用 driver.findElement(By.xpath("//label[contains(text(),'Some text')]")).click();
的结果。
调用 driver.findElement(By.xpath("//label[contains(text(),'Some text')]"));
会返回 null
,但您不会以任何方式断言或验证结果。