我有一個需求來測量Web GUI應用程序中不同功能的UI延遲。使用Selenium/TestNG測試UI性能/延遲
例如要測量登錄操作的延遲
1)輸入用戶名,密碼。
2)點擊登錄按鈕
3)測量點擊登錄按鈕,直到登錄操作完成後的時間。
更好的儀器我認爲是Selenium Grid2,Webdriver,TestNG。以下是登錄測試的示例代碼
@Test
public void testLogin() throws InterruptedException {
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("username"))).sendKeys("admin");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("password"))).sendKeys("admin");
}
@Test
public void testLoginPerf() throws InterruptedException {
webDriver.findElement(By.className("login-button")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("logout-button")));
}
測試運行良好,報告顯示執行的持續時間。
測試testLoginPerf()的執行持續時間是否會給我確切的UI延遲值?有沒有更好的方法來衡量這一點?