Skip to content

Instantly share code, notes, and snippets.

@achingono
Last active January 4, 2016 17:09
Show Gist options
  • Save achingono/8652033 to your computer and use it in GitHub Desktop.
Save achingono/8652033 to your computer and use it in GitHub Desktop.
Assert that a Twitter bootstrap dialog is visible after clicking a button
public class Dialog<TModel> : UiComponent<TModel>
where TModel : class, new()
{
private IWebElement Element
{
get
{
return this.Find.Element(By.CssSelector(".dialog.modal"));
}
}
public bool Visible
{
get
{
// always returns false.
// TODO: Thread.Sleep(500);
return this.Element.Displayed;
}
}
}
[TestClass]
public partial class GroupTests
{
protected IndexPage<GroupModel> indexPage;
protected SampleData<GroupModel> sampleData;
protected Row<GroupModel> row;
[TestInitialize]
public void Initialize()
{
// navigate to the index page
indexPage = Host.Instance
.NavigateToInitialPage<GroupsController, IndexPage<GroupModel>>(
c => c.Index(),
new { area = "Admin" }
);
// create a model with sample data
sampleData = new SampleData<GroupModel>();
// select a random row
row = indexPage.Table.RandomRow();
}
[TestClass]
public partial class AddButton : GroupTests
{
[TestMethod]
public void ShouldBeDisplayed()
{
indexPage.AddButton.Displayed.Should().BeTrue(
reason: "Add button should be visible"
);
}
[TestMethod]
public void ShouldDisplayDialog_WhenClicked()
{
indexPage.AddButton.Click();
// TODO: Wait about 500 milliseconds before asserting
indexPage.Dialog.Visible.Should().BeTrue(
reason: "The modal dialog should be displayed after clicking the 'Add' button"
);
indexPage.Dialog.Cancel();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment