Skip to content

thePantz/CodedUIFluentExtensions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodedUIFluentExtensions

Coded UI Fluent Extensions consists of three parts:

Coded UI Fluent

A set of extensions methods to improve readability and consistency of searching for controls in your UI. There are also several additional UI Test Control implementations for common control types include HTML5 tags, outlook email windows, and IE security warnings. This project only extends the core Coded UI framework and does not introduct any new classes to code against.

Turn this:

[TestInitialize]
public void NavigateToSimpleHtmlControlExamplesPage()
{
    this.window = BrowserWindow.Launch("http://codeduiexamples/Examples/Example1");
}
[TestMethod]
public void ManipulateTextInput()
{
    HtmlDiv bodyContainerDiv = new HtmlDiv(this.window);
    bodyContainerDiv.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "layoutBodyContainer");

    // no fieldset available
    HtmlControl fieldset = new HtmlCustom(bodyContainerDiv);
    fieldset.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "fieldset");

    Assert.IsTrue(fieldset.TryFind());

    HtmlEdit userNameEdit = new HtmlEdit(fieldset);
    userNameEdit.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "usernameInput");

    Assert.IsTrue(string.IsNullOrWhiteSpace(userNameEdit.Text));
    userNameEdit.Text = "MyUserName";
    Assert.IsTrue(StringComparer.Ordinal.Equals(userNameEdit.Text, "MyUserName"));
}

into this

[TestInitialize]
public void NavigateToSimpleHtmlControlExamplesPage()
{
     this.window = BrowserWindow.Launch("http://codeduiexamples/Examples/Example1");
}
[TestMethod]
public void ManipulateTextInput()
{
    var usernameEdit =
      this.window.Find<HtmlDiv>("layoutBodyContainer")
			      .Find<HtmlFieldset>()
			      .Find<HtmlEdit>("usernameInput");
		
    Assert.IsTrue(string.IsNullOrWhiteSpace(usernameEdit.Text));
    usernameEdit.Text = "MyUserName";
    Assert.IsTrue(StringComparer.Ordinal.Equals(usernameEdit.Text, "MyUserName"));
}

Page Modeling Abstraction

Set of platform independent interfaces to describe your UI and allow for a test driven approach to UI development. Using abstractions like IReadWriteValuePageModel for inputs which can read and write some T, you decouple your tests for testing HtmlEdit directly. This makes your tests more robust for when that HtmlEdit changes to a table cell that requires you to first click the cell to revel the some other input. Simply change the implementation of the test (which would have to change anyway). This also allows you to use whatever testing framework you would like to implement the models (eg, Selenium).

Coded UI Implementation of Page Modeling Abstraction

An implementation of the Page Modeling Abstraction using Coded UI. This implementation includes a complete set of extensions that convert default controls into their standard page model equivalents.

Turn this:

[TestInitialize]
public void NavigateToSimpleHtmlControlExamplesPage()
{
    this.window = BrowserWindow.Launch("http://codeduiexamples/Examples/Example1");
}
[TestMethod]
public void ManipulateTextInput()
{
    HtmlDiv bodyContainerDiv = new HtmlDiv(this.window);
    bodyContainerDiv.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "layoutBodyContainer");

    // no fieldset available
    HtmlControl fieldset = new HtmlCustom(bodyContainerDiv);
    fieldset.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "fieldset");

    Assert.IsTrue(fieldset.TryFind());

    HtmlEdit userNameEdit = new HtmlEdit(fieldset);
    userNameEdit.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "usernameInput");

    Assert.IsTrue(string.IsNullOrWhiteSpace(userNameEdit.Text));
    userNameEdit.Text = "MyUserName";
    Assert.IsTrue(StringComparer.Ordinal.Equals(userNameEdit.Text, "MyUserName"));
}

into this:

private ISimpleHtmlControlsPageModel model;
[TestInitialize]
public void NavigateToSimpleHtmlControlExamplesPage()
{
    //BrowserWindow.CurrentBrowser = "Chrome";
    this.model = new SimpleHtmlControlsPageModel(BrowserWindow.Launch("http://codeduiexamples/Examples/Example1"));
}
[TestMethod]
public void ManipulateTextInput()
{
    Assert.IsTrue(String.IsNullOrWhiteSpace(model.UserName.Value));
    model.UserName.SetValue("MyUserName");
    Assert.IsTrue(StringComparer.Ordinal.Equals(model.UserName.Value, "MyUserName"))
}

About

Fluent Syntax for Coded UI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 74.6%
  • JavaScript 24.6%
  • Other 0.8%