I am currently working on creating automated UI tests in C# using Selenium 2 Web Driver for a web application that is built with ASP.NET and MS AJAX. My goal is to integrate custom JavaScript code at the start of each test so that it executes after every asynchronous postback event. Here is an example snippet of the code:
function EndRequestHandler(sender, args)
{
DoSomeStuff(...);
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
My question is how can I achieve this using Selenium without making any modifications to the original application itself? The solution needs to be compatible with IE, Firefox, and Chrome drivers, ruling out the option of using custom profiles for Firefox (unless there is something I'm overlooking).