我正在使Salesforce Web应用程序自动化。登录到应用程序后,将加载主页,然后刷新,由于刷新在2到3秒后发生,因此无法识别定位器。正在刷新以加载仪表板。
Getting an Exception:org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element
我曾尝试过 webdriverwait , Thread.sleep 和 Implicitwait ,但这些选项都不适合我。
public void validatedashboard() throws InterruptedException{
new WebDriverWait(driver, 15).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//button[contains(text(),'Open')]")));
String actualdashboard = dashboard.getText();
BasePage.Log.info(actualdashboard);
String ExpectedText0= "Territory Overview";
if(actualdashboard.contentEquals(ExpectedText0))
{
BasePage.Log.info("Territory Overview dashboard is present");
}
else
{
BasePage.Log.info("Territory Overview dashboard is not present");
}