示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }