Ejemplo n.º 1
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.º 2
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.º 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);
        }