As with the total above, if you are also interested in the client-side performance for the last request, you must call the timeSpentRenderingLastRequest() before calling this method.
totalTimeSpentRendering()
Returns the total time (in milliseconds) spent rendering the user interface of the application on the client-side, that is, in the browser.This time only passes when the browser is rendering after interacting with it through the WebDriver. The timer is shared in the servlet session, so if you have, for example, multiple portlets in the same application (session), their execution times will be included in the same total.
timeSpentRenderingLastRequest()
Returns the time (in milliseconds) spent rendering user interface of the application after the last server request. Notice that not all user interaction through the WebDriver cause server requests.
If you also call the timeSpentServicingLastRequest() or totalTimeSpentServicingRequests(), you should do so before calling this method. The methods cause a server request, which will zero the rendering time measured by this method.
Generally, only interaction with fields in the immediate mode cause server requests.This includes button clicks. Some components, such as Table, also cause requests otherwise, such as when loading data while scrolling. Some interaction could cause multiple requests, such as when images are loaded from the server as the result of user interaction.
The following example is given in the VerifyExecutionTimeITCase.java file under the TestBench examples.
@Test
public void verifyServerExecutionTime() throws Exception { openCalculator();
// Get start time on the server-side
long currentSessionTime = testBench(getDriver())
.totalTimeSpentServicingRequests();
//Interact with the application calculateOnePlusTwo();
//Calculate the passed processing time on the serve-side long timeSpentByServerForSimpleCalculation = testBench()
.totalTimeSpentServicingRequests() - currentSessionTime;
//Report the timing
System.out.println("Calculating 1+2 took about "
+timeSpentByServerForSimpleCalculation
+"ms in servlets service method.");
//Fail if the processing time was critically long if (timeSpentByServerForSimpleCalculation > 30) {
fail("Simple calculation shouldn't take "
+timeSpentByServerForSimpleCalculation + "ms!");
}
//Do the same with rendering time
long totalTimeSpentRendering = testBench().totalTimeSpentRendering();
System.out.println("Rendering UI took " + totalTimeSpentRendering + "ms");
if (timeSpentByServerForSimpleCalculation > 400) {