I use SpecFlow + WatiN + nunit.framework to construct BDD tests for .net
I'd like to check the following functionality on HTML Page:
Scenario: Change user role from 'Admin' to 'User'
Given I have logged in
And I am on the 'Add new user' page
Then the 'Homepage' should not be visible
When I select 'Role' as 'User'
Then the 'Homepage' should be visible
This is a scenario where some property depends on user role. Admin doesn't have Homepage but User does. So the page has an apropriate javascript to show/hide this.
Update: I have made the following method:
[Then(@"'(.*)' (should|should not) be visible")]
public void ThenElementShouldBeVisible(string elementName, string should)
{
var element = WebBrowser.Current.Elements.First(Find.ByLabelText(elementName));
Assert.That(should == "should"
? element.Style.Display == "none"
: element.Style.Display != "none");
}
But it seems to me that the browser object doesn't update the elements style after Javascript has finished work.
I'm not sure how to check if the element is visible or not using SpecFlow.