Hot on the heels of SpecsFor.Mvc 4.0 comes the 4.1.0 release!  This is a minor update, but it adds a very-useful capability.



Selenium WebDriver has always had the ability to wait for certain events to occur, such as a particular element becoming “visible” so that it could be interacted with.  Unfortunately, the code for this was neither clean nor easily discoverable:

new WebDriverWait(Browser, timeout.Value)

Now, with SpecsFor.Mvc, you can call the new WaitForElementToBeVisible helper method instead:

var element = SUT.WaitForElementToBeVisible(By.Id("#some-id"),
    timeout: TimeSpan.FromSeconds(5),
    throwOnTimeout: true);

In its simplest form, this method will wait up to 10 seconds for whatever element you specify using By to become visible, then it will return null.  However, you can customize this behavior by specifying your own timeout or having the helper throw an exception if the element isn’t visible after the timeout expires.

The new bits are on NuGet now, so go get them!