Reputation: 657
I have a requirement to measure UI latency for different functionalities in the web GUI application.
For example to measure latency in Login operation
1) Enter Username, password.
2) Click Login button
3) Measure the time after clicking login button till the login operation completes.
Better instrumentation I thought would be Selenium Grid2, Webdriver, TestNG. Below is the sample code for the login test
@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")));
}
Test runs fine and report shows the duration of execution.
Will the duration of execution of test testLoginPerf() give me exact value of UI latency??? Is there a better way to measure this?
Upvotes: 1
Views: 3133
Reputation: 2573
Check out dynatrace, although I'm not sure if it's more than what you're looking for
Upvotes: 2
Reputation: 155
If you want to measure how much time UI need to show logout-button after click do the following thing:
@Test
public void testLoginPerf() throws InterruptedException {
webDriver.findElement(By.className("login-button")).click();
long start = System.currentTimeMilis();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("logout-button")));
long end = System.currentTimeMilis();
System.out.println("Time: " + (end - start) + " ms);
}
Also don't forget to set sleepInMillis for your wait object small enough to make measurement accurate.
Upvotes: 1