public void ShouldBeAbleToExecuteAsynchronousScripts()
{
driver.Url = ajaxyPage;
IWebElement typer = driver.FindElement(By.Name("typer"));
typer.SendKeys("bob");
Assert.AreEqual("bob", typer.GetAttribute("value"));
driver.FindElement(By.Id("red")).Click();
driver.FindElement(By.Name("submit")).Click();
Assert.AreEqual(1, GetNumberOfDivElements(), "There should only be 1 DIV at this point, which is used for the butter message");
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));
string text = (string)executor.ExecuteAsyncScript(
"var callback = arguments[arguments.length - 1];"
+ "window.registerListener(arguments[arguments.length - 1]);");
Assert.AreEqual("bob", text);
Assert.AreEqual("", typer.GetAttribute("value"));
Assert.AreEqual(2, GetNumberOfDivElements(), "There should be 1 DIV (for the butter message) + 1 DIV (for the new label)");
}