Last active
January 4, 2016 17:09
-
-
Save achingono/8652033 to your computer and use it in GitHub Desktop.
Assert that a Twitter bootstrap dialog is visible after clicking a button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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