/// <summary> /// Initializes a new instance of the <see cref="CodedUIListElementWrapper{TElement, TChildElement}" /> class. /// </summary> /// <param name="parentElement">The parent element.</param> /// <param name="webBrowser">The browser.</param> public CodedUIListElementWrapper(TElement parentElement, IBrowser webBrowser) : base(parentElement, webBrowser) { this.builderFunc = PageBuilder <TElement, TChildElement> .CreateElement(typeof(TChildElement)); this.lockObject = new object(); this.ValidateElementExists = true; }
/// <summary> /// Creates the native page. /// </summary> /// <param name="pageType">Type of the page.</param> /// <returns>The internal document.</returns> private HtmlDocument CreateNativePage(Type pageType) { Func <UITestControl, IBrowser, Action <HtmlControl>, HtmlDocument> function; if (!this.pageCache.TryGetValue(pageType, out function)) { function = PageBuilder <UITestControl, HtmlDocument> .CreateElement(pageType); this.pageCache.Add(pageType, function); } UITestControl parentElement = this.window.Value; // Check to see if a frames reference exists var isFrameDocument = false; PageNavigationAttribute navigationAttribute; if (pageType.TryGetAttribute(out navigationAttribute) && !string.IsNullOrWhiteSpace(navigationAttribute.FrameName)) { Func <UITestControl, HtmlFrame> frameFunction; if (!this.frameCache.Value.TryGetValue(navigationAttribute.FrameName, out frameFunction)) { throw new PageNavigationException( "Cannot locate frame with ID '{0}' for page '{1}'", navigationAttribute.FrameName, pageType.Name); } parentElement = frameFunction(parentElement); isFrameDocument = true; if (parentElement == null) { throw new PageNavigationException( "Cannot load frame with ID '{0}' for page '{1}'. The property that matched the frame did not return a parent document.", navigationAttribute.FrameName, pageType.Name); } } var documentElement = function(parentElement, this, null); if (isFrameDocument) { // Set properties that are relevant to the frame. documentElement.SearchProperties[HtmlDocument.PropertyNames.FrameDocument] = "True"; documentElement.SearchProperties[HtmlDocument.PropertyNames.RedirectingPage] = "False"; } return(documentElement); }