示例#1
0
        public static WatiN.Core.Button GetButton(Div ie, HControl control)
        {
            switch (control.Attribute.ToLower())
            {
            case AttributeType.Id:
            {
                Button bt = ie.Button(Find.ById(control.Value));
                if (bt.Exists)
                {
                    return(bt);
                }
                return(null);
            }

            case AttributeType.Name:
            {
                Button bt = ie.Button(Find.ByName(control.Value));
                if (bt.Exists)
                {
                    return(bt);
                }
                return(null);
            }

            case AttributeType.Class:
            {
                Button bt = ie.Button(Find.ByClass(control.Value));
                if (bt.Exists)
                {
                    return(bt);
                }
                return(null);
            }

            case AttributeType.Text:
            {
                foreach (WatiN.Core.Button bt in ie.Buttons)
                {
                    string s = bt.Text.ToLowerInvariant();
                    s = s.Replace("ð", "đ");
                    if (s == control.Value.ToLower())
                    {
                        return(bt);
                    }
                }
                return(null);
            }

            case AttributeType.Value:
            {
                foreach (WatiN.Core.Button bt in ie.Buttons)
                {
                    string s = bt.Value.ToLowerInvariant();
                    s = s.Replace("ð", "đ");
                    if (s == control.Value.ToLower())
                    {
                        return(bt);
                    }
                }
                return(null);
            }

            default:
            {
                foreach (WatiN.Core.Button bt in ie.Buttons)
                {
                    if (bt.Name == control.Value)
                    {
                        return(bt);
                    }
                }
                return(null);
            }
            }
        }
示例#2
0
        public static WatiN.Core.Button GetButton(Div ie, HControl control)
        {

            switch (control.Attribute.ToLower())
            {
                case AttributeType.Id:
                    {
                        Button bt = ie.Button(Find.ById(control.Value));
                        if (bt.Exists)
                            return bt;
                        return null;
                    }
                case AttributeType.Name:
                    {
                        Button bt = ie.Button(Find.ByName(control.Value));
                        if (bt.Exists)
                            return bt;
                        return null;
                    }
                case AttributeType.Class:
                    {
                        Button bt = ie.Button(Find.ByClass(control.Value));
                        if (bt.Exists)
                            return bt;
                        return null;
                    }
                case AttributeType.Text:
                    {
                        foreach (WatiN.Core.Button bt in ie.Buttons)
                        {
                            string s = bt.Text.ToLowerInvariant();
                            s = s.Replace("ð", "đ");
                            if (s == control.Value.ToLower())
                                return bt;
                        }
                        return null;
                    }
                case AttributeType.Value:
                    {
                        foreach (WatiN.Core.Button bt in ie.Buttons)
                        {
                            string s = bt.Value.ToLowerInvariant();
                            s = s.Replace("ð", "đ");
                            if (s == control.Value.ToLower())
                                return bt;
                        }
                        return null;
                    }
                default:
                    {
                        foreach (WatiN.Core.Button bt in ie.Buttons)
                        {
                            if (bt.Name == control.Value)
                                return bt;
                        }
                        return null;
                    }
            }
        }