Пример #1
0
 public Element BuildElement(WatiN.Core.Element element, string description)
 {
     if (element == null)
     {
         throw new MissingHtmlException(description);
     }
     return(new WatiNElement(element));
 }
Пример #2
0
 private static ElementFound BuildElement(WatiN.Core.Element element, string description)
 {
     if (element == null)
     {
         throw new MissingHtmlException(description);
     }
     return(BuildElement(element));
 }
Пример #3
0
 public WatinControl(WatinBaseControl parent, WatiN.Core.Element element, int idx)
 {
     _parent = parent;
     if (element != null)
     {
         htmlElement = element;
         _index      = idx;
     }
 }
Пример #4
0
 public static WC.ElementContainer <WC.Element> AsElementContainer(this WC.Element element)
 {
     if (element == null)
     {
         throw new NullReferenceException();
     }
     if (!(element is WC.ElementContainer <WC.Element>))
     {
         throw new InvalidCastException(element.GetType().Name + " does not implement ElementContainer<Element>.");
     }
     return(element as WC.ElementContainer <WC.Element>);
 }
Пример #5
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);
        }
Пример #6
0
 private static ElementFound BuildElement(WatiN.Core.Element element)
 {
     return(new WatiNElement(element));
 }
Пример #7
0
 private Element BuildElement(WatiN.Core.Element element)
 {
     return(new WatiNElement(element, Watin));
 }
Пример #8
0
 internal WatiNElement(WatiN.Core.Element watinElement, WatiN.Core.Browser browser)
 {
     this.browser = browser;
     Native       = watinElement;
 }
Пример #9
0
 internal WatiNElement(WatiN.Core.Element watinElement)
 {
     Native = watinElement;
 }
Пример #10
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                //foreach (WatiN.Core.TextField obj in ie.TextFields)
                //{
                //    obj.Highlight(false);
                //}

                //foreach (WatiN.Core.Button obj in ie.Buttons)
                //{
                //    obj.Highlight(false);
                //}
                //foreach (WatiN.Core.Div obj in ie.Divs)
                //{
                //    obj.Highlight(false);
                //}\

                txtSelect.Text = e.Node.Text;
                string Value = e.Node.Text;
                if (Value.IndexOf(" = ") >= 0)
                {
                    Value = Value.Split('=')[1].Trim();
                }
                if (e.Node.FullPath.IndexOf("Div") >= 0)
                {
                    if (txtSelect.Text.IndexOf("Name = ") >= 0)
                    {
                        Div div = ie.Div(Find.ByName(Value));
                        if (div != null && div.Exists)
                        {
                            div.Highlight(true);
                        }
                    }
                    else
                    {
                        Div div = ie.Div(Find.ById(Value));
                        if (div != null && div.Exists)
                        {
                            div.Highlight(true);
                        }
                    }
                }
                else if (e.Node.FullPath.IndexOf("TextBox") >= 0)
                {
                    TextField text = ie.TextField(Find.ByName(Value));
                    if (text != null && text.Exists)
                    {
                        text.Highlight(true);
                        text.Select();
                    }
                }
                else if (e.Node.FullPath.IndexOf("Button") >= 0)
                {
                    WatiN.Core.Button butt = ie.Button(Find.ByValue(Value));
                    if (butt != null && butt.Exists)
                    {
                        butt.Highlight(true);
                    }
                }
                else if (e.Node.FullPath.IndexOf("Link") >= 0)
                {
                    if (txtSelect.Text.IndexOf("Class = ") >= 0)
                    {
                        WatiN.Core.Link link = ie.Link(Find.ByClass(Value));
                        if (link != null && link.Exists)
                        {
                            link.Highlight(true);
                        }
                    }
                    else
                    {
                        WatiN.Core.Link link = ie.Link(Find.ByText(Value));
                        if (link != null && link.Exists)
                        {
                            link.Highlight(true);
                        }
                    }
                }
                else if (e.Node.FullPath.IndexOf("Element") >= 0)
                {
                    if (txtSelect.Text.IndexOf("Id = ") >= 0)
                    {
                        WatiN.Core.Element link = ie.Element(Find.ById(Value));
                        if (link != null && link.Exists)
                        {
                            link.Highlight(true);
                        }
                    }
                    else
                    {
                        WatiN.Core.Element link = ie.Element(Find.ByText(Value));
                        if (link != null && link.Exists)
                        {
                            link.Highlight(true);
                        }
                    }
                }
            }
            catch { }
        }
Пример #11
0
 private bool IsFieldset(WatiN.Core.Element e)
 {
     return(e.TagName == "FIELDSET");
 }
Пример #12
0
 public void ClearScope()
 {
     Scope = null;
 }
Пример #13
0
 private bool IsElementInContainer(WatiN.Core.Element element, IElementContainer container)
 {
     return(container.Children().Any(child => child.Equals(element)));
 }
Пример #14
0
 private bool HasAttribute(WatiN.Core.Element element, string attributeName, string attributeValue)
 {
     return(element.GetAttributeValue(attributeName) == attributeValue);
 }
Пример #15
0
 private bool TextMatches(WatiN.Core.Element element, string expectedText)
 {
     return(!string.IsNullOrEmpty(element.OuterText) && element.OuterText.Trim() == expectedText.Trim());
 }
Пример #16
0
 private bool IsSection(WatiN.Core.Element e)
 {
     return(sectionTagNames.Contains(e.TagName));
 }