Friday, January 25, 2008
Using Selenium to test ASP.NET Ajax UpdatePanel postbacks
Selenium is a really nice tool to do web (regression) testing. With Selenium Remote Control, you can run tests from your C# unit testing code and perform tests on a "remote controlled" browser instance. Very nice.
Recently one of my tests suddenly failed after adding ASP.NET AJAX UpdatePanels to the page. The problem turned out to be that after a Click, we normally issue a WaitForPageToLoad before continuing testing on the next page. This makes sure that the next page (after a postback) is fully loaded before we do the next test action. When using UpdatePanel postbacks, the page is never really submitted and no onLoad event ever happens in the browser. This makes WaitForPageToLoad time out.
Selenium is rather flexible and you can do a lot of custom tests in javascript, but you have to know how. It took me some time, but here it is: make Selenium wait until an UpdatePanel postback has finished:
Comments:
Links to this post:
<< Home
When there is not postback you can also wait for a control to appears:
I think Selenium has the feature.
InCisif.net has also the feature but
the method waits for the control and return the control or time out.
Therefore you can write your code like this
Page.WaitForControl("MyControlId").Click()
Frederic Torres
www.InCisif.net
Web Testing with C# or VB.NET
Post a Comment
I think Selenium has the feature.
InCisif.net has also the feature but
the method waits for the control and return the control or time out.
Therefore you can write your code like this
Page.WaitForControl("MyControlId").Click()
Frederic Torres
www.InCisif.net
Web Testing with C# or VB.NET
Links to this post:
<< Home


