Created
February 14, 2013 13:06
-
-
Save johnnyreilly/4952633 to your computer and use it in GitHub Desktop.
jQuery UI Autocomplete meet Coded UI Tests
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
| // Find the autocomplete input text element | |
| var autocompleteInput = new UITestControl(Browser); | |
| autocompleteInput.TechnologyName = "Web"; | |
| autocompleteInput.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "myAutocomplete"); | |
| autocompleteInput.Find(); | |
| // Find the UL based on the autocomplete input text element | |
| var ul = autocompleteInput.GetAutocompleteUl(); |
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
| using Microsoft.VisualStudio.TestTools.UITesting; | |
| using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls; | |
| namespace MyNamespace.UITests.Utilities | |
| { | |
| public static class UITestControlExtensions | |
| { | |
| /// <summary> | |
| /// Given a supplied input text element, obtain and return the associated Autocomplete UL | |
| /// </summary> | |
| /// <param name="input">input text element</param> | |
| /// <returns>ul element</returns> | |
| public static UITestControl GetAutocompleteUl(this UITestControl input) | |
| { | |
| //Get autocomplete UL from input | |
| var ul = new UITestControl(input.GetParent()); | |
| ul.TechnologyName = "Web"; | |
| ul.SearchProperties.AddRange( | |
| new PropertyExpression(HtmlList.PropertyNames.TagName, "UL"), | |
| new PropertyExpression(HtmlList.PropertyNames.Class, "ui-autocomplete", PropertyExpressionOperator.Contains) | |
| ); | |
| ul.Find(); | |
| return ul; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment