예제 #1
0
        private IEnumerable <WatiN.Core.Element> FindAllXPathDeferred(string xpath, Scope scope, Options options)
        {
            var isVisible = Constraints.IsVisible(options.ConsiderInvisibleElements);

            return(from element in WatiNScope(scope).XPath(xpath)
                   where element.Matches(isVisible)
                   select element);
        }
예제 #2
0
        private IEnumerable <WatiN.Core.Element> FindAllCssDeferred(string cssSelector, Scope scope)
        {
            // TODO: This is restricting by hidden items, but there are no tests for that!
            var isVisible = Constraints.IsVisible(scope.ConsiderInvisibleElements);

            return(from element in WatiNScope(scope).Elements.Filter(Find.BySelector(cssSelector))
                   where element.Matches(isVisible)
                   select element);
        }
예제 #3
0
        public WatiN.Core.Element FindFieldset(string locator, Scope scope)
        {
            var withId     = Find.ById(locator);
            var withLegend = Constraints.HasElement("legend", Find.ByText(locator));
            var hasLocator = withId | withLegend;

            var isVisible = Constraints.IsVisible(scope.ConsiderInvisibleElements);

            return(WatiNScope(scope).Fieldsets().First(hasLocator & isVisible));
        }
예제 #4
0
        public WatiN.Core.Element FindSection(string locator, Scope scope)
        {
            var isSection = Constraints.OfType(typeof(Section), typeof(Div));

            var hasLocator = Find.ById(locator)
                             | Constraints.HasElement(new[] { "h1", "h2", "h3", "h4", "h5", "h6" }, Find.ByText(locator));

            var isVisible = Constraints.IsVisible(scope.ConsiderInvisibleElements);

            return(WatiNScope(scope).Elements.First(isSection & hasLocator & isVisible));
        }
예제 #5
0
        private IEnumerable <WatiN.Core.Element> FindAllXPathDeferred(string xpath, Scope scope, Options options, Regex textPattern = null)
        {
            var whereConstraints = Constraints.IsVisible(options.ConsiderInvisibleElements);

            if (textPattern != null)
            {
                whereConstraints = whereConstraints & Find.ByText(textPattern);
            }

            return(from element in WatiNScope(scope).XPath(xpath)
                   where element.Matches(whereConstraints)
                   select element);
        }
예제 #6
0
        private IEnumerable <WatiN.Core.Element> FindAllCssDeferred(string cssSelector, Scope scope, Options options, Regex textPattern = null)
        {
            // TODO: This is restricting by hidden items, but there are no tests for that!
            var        whereConstraints        = Constraints.IsVisible(options.ConsiderInvisibleElements);
            Constraint querySelectorConstraint = Find.BySelector(cssSelector);

            if (textPattern != null)
            {
                whereConstraints = whereConstraints & Find.ByText(textPattern);
            }

            return(from element in WatiNScope(scope).Elements.Filter(querySelectorConstraint)
                   where element.Matches(whereConstraints)
                   select element);
        }
예제 #7
0
        public WatiN.Core.Element FindButton(string locator, Scope scope)
        {
            var isButton = Constraints.OfType <Button>()
                           | Find.ByElement(e => e.TagName == "INPUT" && e.GetAttributeValue("type") == "image")
                           | Find.By("role", "button");

            var byText             = Find.ByText(locator);
            var byIdNameValueOrAlt = Find.ById(locator)
                                     | Find.ByName(locator)
                                     | Find.ByValue(locator)
                                     | Find.ByAlt(locator);
            var byPartialId = Constraints.WithPartialId(locator);
            var hasLocator  = byText | byIdNameValueOrAlt | byPartialId;

            var isVisible = Constraints.IsVisible(scope.ConsiderInvisibleElements);

            var candidates = WatiNScope(scope).Elements.Filter(isButton & hasLocator & isVisible);

            return(candidates.FirstMatching(byText, byIdNameValueOrAlt, byPartialId));
        }
예제 #8
0
        private WatiN.Core.Element FindFieldByLabel(string locator, Scope scope)
        {
            WatiN.Core.Element field = null;

            var label = WatiNScope(scope).Labels.First(Find.ByText(new Regex(locator)));

            if (label != null)
            {
                var isVisible = Constraints.IsVisible(scope.ConsiderInvisibleElements);

                if (!string.IsNullOrEmpty(label.For))
                {
                    field = WatiNScope(scope).Elements.First(Find.ById(label.For) & isVisible);
                }

                if (field == null)
                {
                    field = label.Elements.First(Constraints.IsField() & isVisible);
                }
            }
            return(field);
        }
예제 #9
0
        public WatiN.Core.Element FindField(string locator, Scope scope)
        {
            var field = FindFieldByLabel(locator, scope);

            if (field == null)
            {
                var isField = Constraints.IsField();

                var byIdOrName    = Find.ById(locator) | Find.ByName(locator);
                var byPlaceholder = Find.By("placeholder", locator);
                var radioButtonOrCheckboxByValue = (Constraints.OfType <RadioButton>() | Constraints.OfType <CheckBox>()) & Find.ByValue(locator);
                var byPartialId = Constraints.WithPartialId(locator);

                var hasLocator = byIdOrName | byPlaceholder | radioButtonOrCheckboxByValue | byPartialId;

                var isVisible = Constraints.IsVisible(scope.ConsiderInvisibleElements);

                var candidates = WatiNScope(scope).Elements.Filter(isField & hasLocator & isVisible);
                field = candidates.FirstMatching(byIdOrName, byPlaceholder, radioButtonOrCheckboxByValue, byPartialId);
            }

            return(field);
        }
예제 #10
0
 public ElementCollection FindElements(string id, Scope scope, Options options)
 {
     return(WatiNScope(scope).Elements.Filter(Find.ById(id) & Constraints.IsVisible(options.ConsiderInvisibleElements)));
 }
예제 #11
0
 public WatiN.Core.Element FindElement(string id, Scope scope)
 {
     return(WatiNScope(scope).Elements.First(Find.ById(id) & Constraints.IsVisible(scope.ConsiderInvisibleElements)));
 }
예제 #12
0
 public WatiN.Core.Element FindLink(string linkText, Scope scope)
 {
     return(WatiNScope(scope).Links.First(Find.ByText(linkText) & Constraints.IsVisible(scope.ConsiderInvisibleElements)));
 }