Пример #1
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));
        }
Пример #2
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);
        }
Пример #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);
        }
Пример #4
0
 public ElementCollection FindElements(string id, Scope scope, Options options)
 {
     return(WatiNScope(scope).Elements.Filter(Find.ById(id) & Constraints.IsVisible(options.ConsiderInvisibleElements)));
 }
Пример #5
0
 public WatiN.Core.Element FindElement(string id, Scope scope)
 {
     return(WatiNScope(scope).Elements.First(Find.ById(id) & Constraints.IsVisible(scope.ConsiderInvisibleElements)));
 }
Пример #6
0
 public WatiN.Core.Element FindLink(string linkText, Scope scope)
 {
     return(WatiNScope(scope).Links.First(Find.ByText(linkText) & Constraints.IsVisible(scope.ConsiderInvisibleElements)));
 }
Пример #7
0
 public Frame FindFrame(string locator, Scope scope)
 {
     return(WatiNDocumentScope(scope).Frames.First(Find.ByTitle(locator) | Find.ByName(locator) | Find.ById(locator) | Constraints.HasElement("h1", Find.ByText(locator))));
 }