示例#1
0
        public HtmlCheckBox GetEmbeddedCheckBox(int iRow, int iCol)
        {
            string       sSearchProperties = "";
            IHTMLElement td         = (IHTMLElement)GetCell(iRow, iCol).UnWrap().NativeElement;
            IHTMLElement check      = GetEmbeddedCheckBoxNativeElement(td);
            string       sOuterHTML = check.outerHTML.Replace("<", "").Replace(">", "").Trim();

            string[] saTemp = sOuterHTML.Split(' ');
            var      chk    = new CUITControls.HtmlCheckBox(SourceControl.Container);

            foreach (string sTemp in saTemp)
            {
                if (sTemp.IndexOf('=') > 0)
                {
                    string[] saKeyValue = sTemp.Split('=');
                    string   sValue     = saKeyValue[1];
                    if (saKeyValue[0].ToLower() == "name")
                    {
                        sSearchProperties += ";Name=" + sValue;
                        chk.SearchProperties.Add(UITestControl.PropertyNames.Name, sValue);
                    }
                    if (saKeyValue[0].ToLower() == "id")
                    {
                        sSearchProperties += ";Id=" + sValue;
                        chk.SearchProperties.Add(CUITControls.HtmlControl.PropertyNames.Id, sValue);
                    }
                    if (saKeyValue[0].ToLower() == "class")
                    {
                        sSearchProperties += ";Class=" + sValue;
                        chk.SearchProperties.Add(CUITControls.HtmlControl.PropertyNames.Class, sValue);
                    }
                }
            }

            if (sSearchProperties.Length > 1)
            {
                sSearchProperties = sSearchProperties.Substring(1);
            }
            HtmlCheckBox retChk = new HtmlCheckBox(sSearchProperties);

            retChk.Wrap(chk);
            return(retChk);
        }
示例#2
0
        private static ControlBase WrapUtil(CUITControls.HtmlControl sourceControl)
        {
            ControlBase control;

            if (sourceControl.GetType() == typeof(CUITControls.HtmlButton))
            {
                control = new HtmlButton((CUITControls.HtmlButton)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlCheckBox))
            {
                control = new HtmlCheckBox((CUITControls.HtmlCheckBox)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlComboBox))
            {
                control = new HtmlComboBox((CUITControls.HtmlComboBox)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlDiv))
            {
                control = new HtmlDiv((CUITControls.HtmlDiv)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlEdit) && (string.Compare(sourceControl.Type, "password", true) == 0))
            {
                control = new HtmlPassword((CUITControls.HtmlEdit)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlEdit))
            {
                control = new HtmlEdit((CUITControls.HtmlEdit)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlEditableDiv))
            {
                control = new HtmlEditableDiv((CUITControls.HtmlEditableDiv)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlFileInput))
            {
                control = new HtmlFileInput((CUITControls.HtmlFileInput)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlHyperlink))
            {
                control = new HtmlHyperlink((CUITControls.HtmlHyperlink)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlImage))
            {
                control = new HtmlImage((CUITControls.HtmlImage)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlInputButton))
            {
                control = new HtmlInputButton((CUITControls.HtmlInputButton)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlLabel))
            {
                control = new HtmlLabel((CUITControls.HtmlLabel)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlList))
            {
                control = new HtmlList((CUITControls.HtmlList)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlRadioButton))
            {
                control = new HtmlRadioButton((CUITControls.HtmlRadioButton)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlSpan))
            {
                control = new HtmlSpan((CUITControls.HtmlSpan)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlEditableSpan))
            {
                control = new HtmlEditableSpan((CUITControls.HtmlEditableSpan)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlTable))
            {
                control = new HtmlTable((CUITControls.HtmlTable)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlCell))
            {
                control = new HtmlCell((CUITControls.HtmlCell)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlTextArea))
            {
                control = new HtmlTextArea((CUITControls.HtmlTextArea)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlIFrame))
            {
                control = new HtmlIFrame((CUITControls.HtmlIFrame)sourceControl);
            }
            else if (sourceControl.GetType() == typeof(CUITControls.HtmlCustom))
            {
                switch (sourceControl.TagName.ToLower())
                {
                case "p":
                    control = new HtmlParagraph((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "h1":
                    control = new HtmlHeading1((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "h2":
                    control = new HtmlHeading2((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "h3":
                    control = new HtmlHeading3((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "h4":
                    control = new HtmlHeading4((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "h5":
                    control = new HtmlHeading5((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "h6":
                    control = new HtmlHeading6((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "ul":
                    control = new HtmlUnorderedList((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "ol":
                    control = new HtmlOrderedList((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "li":
                    control = new HtmlListItem((CUITControls.HtmlCustom)sourceControl);
                    break;

                case "ins":
                    control = new HtmlIns((CUITControls.HtmlCustom)sourceControl);
                    break;

                default:
                    control = new HtmlCustom((CUITControls.HtmlCustom)sourceControl, By.TagName(sourceControl.TagName));
                    break;
                }
            }
            else
            {
                throw new Exception(string.Format("WrapUtil: '{0}' not supported", sourceControl.GetType().Name));
            }

            return(control);
        }