Exemplo n.º 1
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));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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);
        }