Ejemplo n.º 1
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //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;
            Div div = ie.Div(Find.ById(txtSelect.Text));

            if (div != null && div.Exists)
            {
                div.Highlight(true);
            }
            TextField text = ie.TextField(Find.ByName(txtSelect.Text));

            if (text != null && text.Exists)
            {
                text.Highlight(true);
                text.Select();
            }
            WatiN.Core.Button butt = ie.Button(Find.ByValue(txtSelect.Text));
            if (butt != null && butt.Exists)
            {
                butt.Highlight(true);
            }
        }
Ejemplo n.º 2
0
        public ResultWindow(int timeLimit, string idProblem) : this()
        {
            this.timeLimit = timeLimit;
            this.idProblem = idProblem;
            Process process = new Process();

            process.StartInfo.WindowStyle     = ProcessWindowStyle.Hidden;
            process.StartInfo.CreateNoWindow  = true;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.FileName        = "cmd";
            process.StartInfo.Arguments       =
                string.Format("/C \"\"{0}\" < \"{1}\" > \"{2}\"\"",
                              Properties.Settings.Default.FileExec,
                              Properties.Settings.Default.FileInput,
                              Properties.Settings.Default.FileOutput);
            process.Start();
            if (!process.WaitForExit(timeLimit * 1000))
            {
                process.Kill();
            }
            if (process.ExitCode != 0)
            {
                runtime.Visibility = Visibility.Visible;
                return;
            }
            timeExec.Content = process.TotalProcessorTime.Milliseconds / 1000f + "s";
            try
            {
                textInput  = File.ReadAllText(Properties.Settings.Default.FileInput);
                textOutput = File.ReadAllText(Properties.Settings.Default.FileOutput);
                textOutput = textOutput.Replace("\r\n", "\n");
                //Settings.MakeNewIeInstanceVisible = false;
                WatiN.Core.Settings.Instance.AutoMoveMousePointerToTopLeft = false;
                browser = new IE(prefix + idProblem);
                TextField         inputField   = browser.TextField(Find.ById("edit-input-data"));
                WatiN.Core.Button buttonSubmit = browser.Button(Find.ById("edit-output"));
                inputField.Value = textInput;
                buttonSubmit.Click();
                browser.WaitForComplete();
                string result = browser.Html;
                int    begin  = result.IndexOf("<pre>") + 5;
                textCorrect = result.Substring(begin, result.IndexOf("</pre>") - begin);
                File.WriteAllText(Properties.Settings.Default.FileCorrect, textCorrect);
                if (textOutput != textCorrect)
                {
                    incorrect.Visibility = Visibility.Visible;
                }
                else
                {
                    accepted.Visibility = Visibility.Visible;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            browser.ForceClose();
        }
Ejemplo n.º 3
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //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);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private static string RunControlConfirm(List <HControl> controls, IE ie)
        {
            int    i      = 0;
            string status = "Error";

            while (i < Loop)
            {
                i++;
                foreach (HControl control in controls)
                {
                    switch (control.Control.ToLower())
                    {
                    case ControlType.AHref:
                    {
                        WatiN.Core.Link obj = MyWatiN.GetLink(ie, control);
                        if (obj != null)
                        {
                            ConfirmDialogHandler approveConfirmDialog = new ConfirmDialogHandler();
                            using (new UseDialogOnce(ie.DialogWatcher, approveConfirmDialog))
                            {
                                obj.ClickNoWait();
                                approveConfirmDialog.WaitUntilExists();
                                approveConfirmDialog.OKButton.Click();
                                ie.WaitForComplete();
                                return(String.Empty);
                            }
                        }
                        break;
                    }

                    case ControlType.Link:
                    {
                        WatiN.Core.Link obj = MyWatiN.GetLink(ie, control);
                        if (obj != null)
                        {
                            ConfirmDialogHandler approveConfirmDialog = new ConfirmDialogHandler();
                            using (new UseDialogOnce(ie.DialogWatcher, approveConfirmDialog))
                            {
                                obj.ClickNoWait();
                                approveConfirmDialog.WaitUntilExists();
                                approveConfirmDialog.OKButton.Click();
                                ie.WaitForComplete();
                                return(String.Empty);
                            }
                        }
                        break;
                    }

                    case ControlType.Button:
                    {
                        WatiN.Core.Button obj = MyWatiN.GetButton(ie, control);
                        if (obj != null)
                        {
                            ConfirmDialogHandler approveConfirmDialog = new ConfirmDialogHandler();
                            using (new UseDialogOnce(ie.DialogWatcher, approveConfirmDialog))
                            {
                                obj.ClickNoWait();
                                approveConfirmDialog.WaitUntilExists();
                                approveConfirmDialog.OKButton.Click();
                                ie.WaitForComplete();
                                return(String.Empty);
                            }
                        }
                        break;
                    }

                    case ControlType.Div:
                    {
                        WatiN.Core.Div obj = MyWatiN.GetDiv(ie, control);
                        if (obj != null)
                        {
                            ConfirmDialogHandler approveConfirmDialog = new ConfirmDialogHandler();

                            using (new UseDialogOnce(ie.DialogWatcher, approveConfirmDialog))
                            {
                                obj.ClickNoWait();
                                approveConfirmDialog.WaitUntilExists();
                                approveConfirmDialog.OKButton.Click();
                                ie.WaitForComplete();
                                return(String.Empty);
                            }
                        }
                        break;
                    }
                    }
                }
                Thread.Sleep(1000);
            }
            return(status);
        }
Ejemplo n.º 5
0
        public static string RunControl(List <HControl> controls, string data, IE ie)
        {
            int    i      = 0;
            string status = "Error";

            while (i < Loop)
            {
                i++;
                foreach (HControl control in controls)
                {
                    switch (control.Control.ToLower())
                    {
                    case ControlType.AHref:
                    {
                        WatiN.Core.Link obj = MyWatiN.GetLink(ie, control);
                        if (obj != null)
                        {
                            obj.Click();
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.AHrefNoText:
                    {
                        ie.GoTo(control.Value);
                        ie.WaitForComplete();
                        return(String.Empty);

                        break;
                    }

                    case ControlType.Link:
                    {
                        WatiN.Core.Link obj = MyWatiN.GetLink(ie, control);
                        if (obj != null)
                        {
                            obj.Click();
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.Button:
                    {
                        WatiN.Core.Button obj = MyWatiN.GetButton(ie, control);
                        if (obj != null)
                        {
                            obj.Click();
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.Div:
                    {
                        WatiN.Core.Div obj = MyWatiN.GetDiv(ie, control);
                        if (obj != null)
                        {
                            obj.Click();
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.Image:
                    {
                        WatiN.Core.Image obj = MyWatiN.GetImage(ie, control);
                        if (obj != null)
                        {
                            obj.Click();
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.TextArea:
                    {
                        WatiN.Core.TextField obj = MyWatiN.GetTextField(ie, control);
                        if (obj != null)
                        {
                            obj.Value = data;
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.TextBox:
                    {
                        WatiN.Core.TextField obj = MyWatiN.GetTextField(ie, control);
                        if (obj != null)
                        {
                            obj.Value = data;
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.CheckBox:
                    {
                        WatiN.Core.CheckBox obj = MyWatiN.GetCheckBox(ie, control);
                        if (obj != null)
                        {
                            obj.Checked = bool.Parse(data);
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }
                    }
                }
                Thread.Sleep(1000);
            }
            return(status);
        }
Ejemplo n.º 6
0
        public static string RunControl(List <HControl> controls, string data, Div div, IE ie)
        {
            int    i      = 0;
            string status = "Error";

            while (i < Loop)
            {
                i++;
                foreach (HControl control in controls)
                {
                    switch (control.Control.ToLower())
                    {
                    case ControlType.Link:
                    {
                        WatiN.Core.Link obj = MyWatiN.GetLink(div, control);
                        if (obj != null)
                        {
                            obj.Click();
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.Button:
                    {
                        WatiN.Core.Button obj = MyWatiN.GetButton(div, control);
                        if (obj != null)
                        {
                            obj.Click();
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.Image:
                    {
                        WatiN.Core.Image obj = MyWatiN.GetImage(div, control);
                        if (obj != null)
                        {
                            obj.Click();
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.TextArea:
                    {
                        WatiN.Core.TextField obj = MyWatiN.GetTextField(div, control);
                        if (obj != null)
                        {
                            obj.Value = data;
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.TextBox:
                    {
                        WatiN.Core.TextField obj = MyWatiN.GetTextField(div, control);
                        if (obj != null)
                        {
                            obj.Value = data;
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }

                    case ControlType.CheckBox:
                    {
                        WatiN.Core.CheckBox obj = MyWatiN.GetCheckBox(div, control);
                        if (obj != null)
                        {
                            obj.Checked = true;
                            ie.WaitForComplete();
                            return(String.Empty);
                        }
                        break;
                    }
                    }
                }
                if (i < Loop - 1)
                {
                    Thread.Sleep(1000);
                }
            }
            return(status);
        }
Ejemplo n.º 7
0
        public static bool CheckExist(List <HControl> controls, IE ie)
        {
            int  i      = 0;
            bool status = false;

            while (i < 2)
            {
                i++;
                foreach (HControl control in controls)
                {
                    switch (control.Control.ToLower())
                    {
                    case ControlType.AHref:
                    {
                        WatiN.Core.Link obj = MyWatiN.GetLink(ie, control);
                        if (obj != null)
                        {
                            return(true);
                        }
                        break;
                    }

                    case ControlType.Link:
                    {
                        WatiN.Core.Link obj = MyWatiN.GetLink(ie, control);
                        if (obj != null)
                        {
                            return(true);
                        }
                        break;
                    }

                    case ControlType.Button:
                    {
                        WatiN.Core.Button obj = MyWatiN.GetButton(ie, control);
                        if (obj != null)
                        {
                            return(true);
                        }
                        break;
                    }

                    case ControlType.Div:
                    {
                        WatiN.Core.Div obj = MyWatiN.GetDiv(ie, control);
                        if (obj != null)
                        {
                            return(true);
                        }
                        break;
                    }

                    case ControlType.Image:
                    {
                        WatiN.Core.Image obj = MyWatiN.GetImage(ie, control);
                        if (obj != null)
                        {
                            return(true);
                        }
                        break;
                    }

                    case ControlType.TextArea:
                    {
                        WatiN.Core.TextField obj = MyWatiN.GetTextField(ie, control);
                        if (obj != null)
                        {
                            return(true);
                        }
                        break;
                    }

                    case ControlType.TextBox:
                    {
                        WatiN.Core.TextField obj = MyWatiN.GetTextField(ie, control);
                        if (obj != null)
                        {
                            return(true);
                        }
                        break;
                    }

                    case ControlType.CheckBox:
                    {
                        WatiN.Core.CheckBox obj = MyWatiN.GetCheckBox(ie, control);
                        if (obj != null)
                        {
                            return(true);
                        }
                        break;
                    }
                    }
                }
                if (i < 1)
                {
                    Thread.Sleep(1000);
                }
            }
            return(status);
        }
Ejemplo n.º 8
0
        private WatinControl CreateWatinControl(INativeElement htmlElem)
        {
            Element          watElem;
            WatinBaseControl watBaseTypeElem;
            int    watElemIndex = 0;
            int    sourceIdx    = htmlElem.GetElementSourceIndex();
            string getByTag     = htmlElem.TagName;

            switch (getByTag)
            {
            case "AREA":
                watElem         = new Area(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Areas);
                IEnumerator <Area> areaEnum = docElement.Areas.GetEnumerator();

                while (areaEnum.MoveNext())
                {
                    if (areaEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "INPUT":
                string byType = htmlElem.GetAttributeValue("type");
                switch (byType)
                {
                case "submit":
                case "reset":
                case "button":
                    watElem         = new WatiN.Core.Button(docElement.DomContainer, htmlElem);
                    watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Buttons);
                    IEnumerator <WatiN.Core.Button> buttonEnum = docElement.Buttons.GetEnumerator();

                    while (buttonEnum.MoveNext())
                    {
                        if (buttonEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                        {
                            break;
                        }
                        watElemIndex++;
                    }
                    return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

                case "checkbox":
                    watElem         = new WatiN.Core.CheckBox(docElement.DomContainer, htmlElem);
                    watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.CheckBoxes);
                    IEnumerator <WatiN.Core.CheckBox> cbEnum = docElement.CheckBoxes.GetEnumerator();

                    while (cbEnum.MoveNext())
                    {
                        if (cbEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                        {
                            break;
                        }
                        watElemIndex++;
                    }
                    return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

                case "file":
                    watElem         = new FileUpload(docElement.DomContainer, htmlElem);
                    watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.FileUploads);
                    IEnumerator <FileUpload> fuEnum = docElement.FileUploads.GetEnumerator();

                    while (fuEnum.MoveNext())
                    {
                        if (fuEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                        {
                            break;
                        }
                        watElemIndex++;
                    }
                    return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

                case "hidden":
                case "password":
                case "text":
                case "textarea":
                    watElem         = new TextField(docElement.DomContainer, htmlElem);
                    watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.TextFields);
                    IEnumerator <TextField> tfEnum = docElement.TextFields.GetEnumerator();

                    while (tfEnum.MoveNext())
                    {
                        if (tfEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                        {
                            break;
                        }
                        watElemIndex++;
                    }
                    return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

                case "radio":
                    watElem         = new WatiN.Core.RadioButton(docElement.DomContainer, htmlElem);
                    watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.RadioButtons);
                    IEnumerator <WatiN.Core.RadioButton> rbEnum = docElement.RadioButtons.GetEnumerator();

                    while (rbEnum.MoveNext())
                    {
                        if (rbEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                        {
                            break;
                        }
                        watElemIndex++;
                    }
                    return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));
                }
                break;

            case "DIV":
                watElem         = new Div(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Divs);
                IEnumerator <Div> divEnum = docElement.Divs.GetEnumerator();

                while (divEnum.MoveNext())
                {
                    if (divEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "FORM":
                watElem         = new WatiN.Core.Form(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Forms);
                IEnumerator <WatiN.Core.Form> formEnum = docElement.Forms.GetEnumerator();

                while (formEnum.MoveNext())
                {
                    if (formEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "FRAME":
            case "IFRAME":
                //watFrame = new Frame(browser.DomContainer, htmlElem);
                //watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Forms);
                //IEnumerator<Form> formEnum = browser.Forms.GetEnumerator();

                //while (formEnum.MoveNext())
                //{
                //	  if (formEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                //		  break;
                //	  watElemIndex++;
                //}
                //return new WatinControl(watBaseTypeElem, watElem, watElemIndex);
                break;

            case "IMG":
                watElem         = new Image(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Images);
                IEnumerator <Image> imgEnum = docElement.Images.GetEnumerator();

                while (imgEnum.MoveNext())
                {
                    if (imgEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "LABLE":
                watElem         = new WatiN.Core.Label(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Labels);
                IEnumerator <WatiN.Core.Label> lblEnum = docElement.Labels.GetEnumerator();

                while (lblEnum.MoveNext())
                {
                    if (lblEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "A":
                watElem         = new Link(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Links);
                IEnumerator <Link> lnkEnum = docElement.Links.GetEnumerator();

                while (lnkEnum.MoveNext())
                {
                    if (lnkEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "P":
                watElem         = new Para(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Paras);
                IEnumerator <Para> paraEnum = docElement.Paras.GetEnumerator();

                while (paraEnum.MoveNext())
                {
                    if (paraEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "SELECT":
                watElem         = new SelectList(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.SelectLists);
                IEnumerator <SelectList> slEnum = docElement.SelectLists.GetEnumerator();

                while (slEnum.MoveNext())
                {
                    if (slEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "SPAN":
                watElem         = new Span(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Spans);
                IEnumerator <Span> spanEnum = docElement.Spans.GetEnumerator();

                while (spanEnum.MoveNext())
                {
                    if (spanEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "TBODY":
                watElem         = new TableBody(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.TableBodies);
                IEnumerator <TableBody> tbEnum = docElement.TableBodies.GetEnumerator();

                while (tbEnum.MoveNext())
                {
                    if (tbEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "TD":
                watElem         = new TableCell(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.TableCells);
                IEnumerator <TableCell> tdEnum = docElement.TableCells.GetEnumerator();

                while (tdEnum.MoveNext())
                {
                    if (tdEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "TR":
                watElem         = new TableRow(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.TableRows);
                IEnumerator <TableRow> trEnum = docElement.TableRows.GetEnumerator();

                while (trEnum.MoveNext())
                {
                    if (trEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "TABLE":
                watElem         = new Table(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.Tables);
                IEnumerator <Table> tableEnum = docElement.Tables.GetEnumerator();

                while (tableEnum.MoveNext())
                {
                    if (tableEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            case "TEXTAREA":
                watElem         = new TextField(docElement.DomContainer, htmlElem);
                watBaseTypeElem = new WatinBaseControl(this, WatinBaseTypes.TextFields);
                IEnumerator <TextField> taEnum = docElement.TextFields.GetEnumerator();

                while (taEnum.MoveNext())
                {
                    if (taEnum.Current.NativeElement.GetElementSourceIndex() == sourceIdx)
                    {
                        break;
                    }
                    watElemIndex++;
                }
                return(new WatinControl(watBaseTypeElem, watElem, watElemIndex));

            default:
                return(null);
            }

            return(null);
        }