/// <summary> /// Returns the first element from the rendered fragment or component under test, /// using the provided <paramref name="cssSelector"/>, in a depth-first pre-order traversal /// of the rendered nodes. /// </summary> /// <param name="renderedFragment">The rendered fragment to search.</param> /// <param name="cssSelector">The group of selectors to use.</param> public static IElement Find(this IRenderedFragment renderedFragment, string cssSelector) { if (renderedFragment is null) { throw new ArgumentNullException(nameof(renderedFragment)); } var result = renderedFragment.Nodes.QuerySelector(cssSelector); if (result is null) { throw new ElementNotFoundException(cssSelector); } return(WrapperFactory.Create(new ElementFactory <IElement>(renderedFragment, result, cssSelector))); }