【发布时间】:2018-03-10 08:18:50
【问题描述】:
当 clickevent 被触发时,我希望它在同一个选项卡中重定向/打开新页面。新选项卡将是“/Waiting”,但是即使在触发单击事件后,它仍会保留在同一页面中。通过转到浏览器的本地主机手动进行时,它可以工作。此外,即使在 10 秒后,它也不会加载。
@Test
public void firstPlayerConnection() {
try {
driver.get(uiPath);
WebElement startGame = driver.findElement(By.id("startGame"));
startGame.click();
WebElement gif = (new WebDriverWait(driver, 10))
.until(ExpectedConditions.presenceOfElementLocated(By.id("loading")));
assertEquals("/Waiting", driver.getCurrentUrl());
} finally {
driver.quit();
}
}
【问题讨论】:
-
startGame.click()是否出现空指针异常? -
任何 Selenium 异常抛出,如 NoSuchElement、ElementNotVisible 等?
-
是的。由于页面没有加载,它说 nosuchelement
-
当您的问题所在的代码中出现异常时,请始终提供异常的堆栈跟踪,并明确发生此异常的代码行。这样可以更轻松地快速回答您的问题。
-
noSuchElement 异常不是因为页面没有加载,而是因为 startGame 按钮在你点击它的那一刻是不可点击的。
标签: java selenium testing web junit