Telerik blogs
Since Selenium has been designed as a browser-oriented tool, load/performance tests definitely aren’t among its strong points. With the help of Selenium Remote Control  one can make precise performance test in his/her preferred language (executing number of opening page steps for example and calculating the average time), but I will limit this post in a really simple example test based entirely on Selenium Core.

I’ve used RadGrid as a complex Web Control to check whether its execution time exceeds over an accepted period. What the Selenium Core test needs is just a result available for verification. So adding the execution time as text on the page will best simplify our Selenium test.

In order to fix the control execution precisely, my test class inherits from RadGrid, overriding its Init and Render events.



I check the starting time prior to control initialization (Base.OnInit) and calculate the time as soon as our grid is rendered (Base.Render). I extend the rendering adding the calculated time into a span element below the Grid. The result looks like this:



Now our Selenium test looks much straight-forward. All I do is to perform a simple text check (using assertTextPresent for example) to verify that the rendered text contains “00:00:00”, which will assure that the execution time has not passed over a second.



As simple as possible, isn’t it?

Of course, one can modify the test by rendering the required text in format per his/her requirements or limit the allowed control execution more strictly.

I have attached a sample web site including the inherited class (in App_Code) and a web page with the test grid demo.

RadGridExecutionTimeWebSite.zip

Comments

Comments are disabled in preview mode.