您永远无法确定会找到该元素,实际上这是功能测试的目的-
告诉您页面上是否有任何更改。但有一两件事肯定是有帮助是添加等待这往往导致元素
NoSuchElementException像
WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);wait.until(ExpectedConditions.visibilityOfElementLocated(By.id<locator>));

您永远无法确定会找到该元素,实际上这是功能测试的目的-
告诉您页面上是否有任何更改。但有一两件事肯定是有帮助是添加等待这往往导致元素
NoSuchElementException像
WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);wait.until(ExpectedConditions.visibilityOfElementLocated(By.id<locator>));