Microsoft.Services.TestTools.UITesting.Html

Types


IWebUITestConfiguration

Web UI Test Configuration

            [Export(typeof(IWebUITestConfiguration))]
            public class TestConfiguration : IWebUITestConfiguration {
               public Uri GetBaseUri(string name) {
                  if (name == "Intra") {
                     return new Uri("http://intranet.contoso.local");
                   }
                   return new Uri("http://www.contoso.local");
               }
            }
            

Remarks

Export a type in your test project that inherits IWebUITestConfiguration in order to provide a base address for your Page objects.

See also

BaseUriAttribute

IWebUITestConfiguration.GetBaseUri(String)

Gets the base Uri

ObjectExtensions

Object extension methods

ObjectExtensions.ForEachProperty(Object,Action{String,String})

Executes the provided Action for each public property on the object. It passes the name and the value of the property to the action.

Page

Page Object base class

Remarks

Use this base class to simplify the implementation of the Page Object pattern.

Page.Launch<T>

Launches the specified page.

            var home = Page.Launch<Home>();
            

See also

EntryUriAttribute
BaseUriAttribute
ClearCookiesAttribute
ClearCacheAttribute

Page.Launch<T>(Boolean,Boolean)

Launches the specified page.

            var home = Page.Launch<Home>(false,true);
            

Remarks

Ignores the ClearCookiesAttribute and ClearCacheAttribute

See also

EntryUriAttribute
BaseUriAttribute
ClearCookiesAttribute
ClearCacheAttribute

Page.ShouldClearCache<T>

Checks if the current page is decorated with the ClearCacheAttribute.

Page.ShouldClearCookies<T>

Checks if the current page is decorated with the ClearCookiesAttribute.

Page.HasAttribute<T, A>

Determines whether the page has the specified attribute.

Page.GetAttribute<T, A>

Gets the attribute.

Page.GetLaunchUri<T>(T)

Gets the launch Uri for the specified page.

Page._container

MEF composition container.

Page.LoadConfiguration<T>(T)

Initializes the composition container and loads the configuration

Page.NavigatedTo<T>

Returns a new page instance and forwards the browser instance to the new page.

            Browser.ClickOnButton("Home");
            return NavigatedTo<Home>();
            


Page.Refresh

Refreshes this instance.

Page.Close

Closes this instance.

Page.TestConfiguration

Gets or sets the test configuration.

See also

IWebUITestConfiguration

Page.Browser

Gets or sets the browser.

PageTest<T>

Base class used to simplify tests utilizing Page 's

            [CodedUITest]
            public class HomeTests : PageTest<Home> {
            
                [TestMethod]
                public void MainMenuContainsHome() {
                    Assert.IsTrue(TestedPage.MainMenuContainsItem("Home"));
                }
            }
            


PageTest<T>.Initialize()

Initializes this instance.

PageTest<T>.Cleanup()

Cleanups this instance.

PageTest<T>.Name()

Generates a name

Remarks

Form input helper

See also

PageTest<T>.StringCreator

PageTest<T>.Amount()

Generates an amount

Remarks

Form input helper

See also

PageTest<T>.StringCreator

PageTest<T>.Email()

Generates an email address

Remarks

Form input helper

See also

PageTest<T>.StringCreator

PageTest<T>.Password()

Generates a password

Remarks

Form input helper

See also

PageTest<T>.StringCreator

PageTest<T>.TestedPage

Gets or sets the tested page.

PageTest<T>.StringCreator

Gets the string creator

Remarks

For most cases the methods Name(), Amount(), Email(), Password() will probably be sufficient. Access this field if you want to generate more specialized strings

StringCreator

Helper class used to generate form input strings

StringCreator.Upper

Upper case letters for randomization

StringCreator.International

International letters for randomization

StringCreator.Numbers

Digits for randomization

StringCreator.Special

Special characters for randomization

StringCreator.Lower

Lower chase letters used for randomizaton

StringCreator.Randomizer

Randomizer used by the create mathods

StringCreator.Create(String,Int32)

Create a random string using the source characters provided.

StringCreator.CreateName()

Creates a name. 8 chars.

Remarks

Uppercase, Lowercase, and International chars

StringCreator.CreateName(Int32)

Creates a name.

Remarks

Uppercase, Lowercase, and International chars

StringCreator.CreatePassword()

Creates a password. 12 chars.

Remarks

Uppercase, Lowercase, Numbers, International and Special chars

StringCreator.CreatePassword(Int32)

Creates a password.

Remarks

Uppercase, Lowercase, Numbers International and Special chars

StringCreator.CreateEmail()

Creates an email address. 16 chars

StringCreator.CreateEmail(Int32)

Creates an email address.

StringCreator.CreateAmount()

Creates an amount. Two decimals.

StringCreator.CreateAmount(Int32,Int32)

Creates an amount.

StringCreator.CreateAmount(Int32,Int32,IFormatProvider)

Creates an amount.

StringCreator.CreateNumeric()

Creates a number. 4 digits

StringCreator.CreateNumeric(Int32)

Creates a number.

UITestControlExtensions

UITestControl extension methods

UITestControlExtensions.Click(UITestControl)

Clicks on the control.

Remarks

The method waits for control to exist and that it's clickable

UITestControlExtensions.Click(UITestControl,Drawing.Point)

Clicks on the control.

UITestControlExtensions.Click(UITestControl,Object)

Clicks on the matching control

            //launch the browser
            BrowserWindow browser = BrowserWindow.Launch(new Uri("..."));
            //find a control with id "ButtonId" and then click on it
            browser.Click(new { Id = "ButtonId" });
            


UITestControlExtensions.ClickOnLink(UITestControl,String)

Clicks on a HtmlControls.HtmlHyperlink with the specified inner text.

UITestControlExtensions.ClickOnButton(UITestControl,String)

Clicks on a button with the specified text.

Remarks

This method will fist search for a HtmlControls.HtmlButton (HTML tag "button") with the specified text and click on it. If no matching HtmlButton is found the method will instead search for a HtmlControls.HtmlInputButton (HTML tag "input" with type attribute equal to "button").

UITestControlExtensions.Check(UITestControl,String)

Checks a HtmlControls.HtmlCheckBox with the specified Id.

UITestControlExtensions.Check(UITestControl,Object)

Checks a HtmlControls.HtmlCheckBox matching the specified criteras.

UITestControlExtensions.SetEditText(UITestControl,Object,String)

Sets the text of the matching HtmlControls.HtmlEdit .

UITestControlExtensions.SetEditText(UITestControl,String,String)

Sets the text of the HtmlControls.HtmlEdit with the specified Id.

UITestControlExtensions.SetEditTexts(UITestControl,Object)

Sets the text of multiple HtmlControls.HtmlEdit 's.

            browser.SetEditTexts(new {
                FirstName = "First",
                LastName  = "Last"
            });
            

Remarks

This method can be usefull when filling out big forms. The is an anonymous type (object) with properties matching the Id's of the HtmlControls.HtmlEdit 's you want to set the text on.

UITestControlExtensions.Select(UITestControl,String,Int32)

Selects the item with the specified index in the HtmlControls.HtmlComboBox with the specified id.

UITestControlExtensions.Select(UITestControl,String,String)

Selects the item with the specified text in the HtmlControls.HtmlComboBox with the specified id.

UITestControlExtensions.Find(UITestControl,String)

Finds the HtmlControls.HtmlControl with the specified Id.

UITestControlExtensions.Find(UITestControl,Object)

Finds the HtmlControls.HtmlControl matching the specified criterias.

            HtmlControl control = browser.Find(new { TagName = "A" });
            

Remarks

The property names on the find criteria object must to match a property name defined in the accompanying HtmlControls.HtmlControl.PropertyNames object.

See also

UITestControlExtensions.Filter<T>(T,Object)

UITestControlExtensions.Find<T>(UITestControl)

Finds a control of the specified type.

            HtmlTable onlyTable = browser.Find<HtmlTable>();
            


UITestControlExtensions.Find<T>(UITestControl,String)

Finds the control with the specified id.

Remarks

This method will search for controls which id contains the specified id. This is especially convenient when dealing with ASP.NET generated id's.

UITestControlExtensions.Find<T>(UITestControl,String,PropertyExpressionOperator)

Finds the control with the specified id.

UITestControlExtensions.Find<T>(UITestControl,Object)

Finds the control matching the specified criterias.

            HtmlButton button = browser.Find<HtmlButton>(new { Id = "MyButton" });
            button.Click();
            


UITestControlExtensions.Find<T>(UITestControl,Object,PropertyExpressionOperator)

Finds the control matching the specified criterias.

            HtmlButton button = browser.Find<HtmlButton>(new { Id = "MyButton" }, PropertyExpressionOperator.Contains);
            button.Click();
            


UITestControlExtensions.Find<T>(UITestControl,String,String)

Finds the control with a HtmlControls.HtmlControl.PropertyNames.ControlDefinition containing the specified attribute with the specified value.

            HtmlSpan validationSpan = browser.Find<HtmlSpan>("data-valmsg-for", "FieldName");
            string validationMessage = validationSpan.InnerText;
            

Remarks

This method is primarily used for attributes that're not available in the PropertyNames collection. For instance "data dash" attributes (data-*).

UITestControlExtensions.IfExists<T>(UITestControl,Object,Action{T})

Performs the provided acton if the specified control exists

            browser.IfExists<HtmlHyperlink>(new { InnerText = "Log Off"}, e => e.Click());
            


UITestControlExtensions.Instance<T>(T,Int32)

Returns the specified control instance

            browser
                .Find<HtmlComboBox>()
                .Instance(2)
                .SelectedItem = "SelectMe";
            

Remarks

When the find method finds multiple matching controls this method can be used to retrieve a single control from the collection

UITestControlExtensions.Filter<T>(T,Object)

Adds the specified filter properties to the element

            browser
                .Find<HtmlCell>()
                .Filter(new {
                    RowIndex    = "3"
                    ColumnIndex = "2"
                });
            

Remarks

Applied after search properties. Must be predecessed by Find.

UITestControlExtensions.GetInnerText(UITestControl)

Gets the inner text of the control.

Remarks

If the control isn't a HtmlControls.HtmlControl , String.Empty will be returned

UITestControlExtensions.GetValueInCell(HtmlControls.HtmlTable,Int32,Int32)

Gets the inner text of a table cell

ClearCookiesAttribute

Decorate your Page with this attribute to tell the Page launcher to clear the browser cookies prior page launch.

ClearCacheAttribute

Decorate your Page with this attribute to tell the Page launcher to clear the browser cache prior page launch.

BaseUriAttribute

Use the BaseUriAttribute to specify an alternative base uri to be used by the Page launcher.

            [BaseUriAttribute("Shop")]
            public class Shop : Page {
            //impl omitted
            }
            


BaseUriAttribute.#ctor(String)

Initializes a new instance of the BaseUriAttribute class.

BaseUriAttribute.BaseUriName

Gets the name of the base Uri.

EntryUriAttribute

Decorate your Page with this attribute to set its relative entry Uri.

            [EntryUri("/Account/LogOn")]
            public class LogOn : Page {
            //impl omitted
            }
            

Remarks

The base Uri is handeled by the exported IWebUITestConfiguration type

EntryUriAttribute.#ctor(String)

Initializes a new instance of the EntryUriAttribute class.

EntryUriAttribute.RelativeUri

Gets the relative Uri.

RelativeUri

A relative Uri

RelativeUri.#ctor(String)

Initializes a new instance of the RelativeUri class.

Last edited Mar 8, 2012 at 9:28 PM by chrislof, version 1

Comments

No comments yet.