Пример #1
0
        //string oldtest = null

        public static bool RunStep(string test, string dep, string Type, string Page, string URL, string load, string reload, string Elem, By str, string disp, string act, string val, string Exp, int pause, int waitParm)
        {
            bool Rtn = true;


            int timer = waitParm;

            if (Type == "GUI" && TestRun.Driver == null)
            {
                log.Error("No web driver has been allocated for browser " + Config.Browser + ". GUI test: " + test + " ,step skipped");
                return(false);
            }

            if (load == "Yes")
            {
                TestRun.Driver.Navigate().GoToUrl(Config.GUIurl + URL);
            }
            if (reload == "Yes")
            {
                TestRun.Driver.Navigate().GoToUrl(TestRun.Driver.Url);
            }

            if (pause > 0)
            {
                Thread.Sleep(pause);
            }

            if (disp == "Yes")
            {
                if (!SeleniumActions.RunTest(str, timer, Elem, TestRun.Driver))
                {
                    log.Error("Error finding element " + Elem);
                    return(false);
                }
            }
            switch (act)
            {
            case "None":
                return(true);

            case "Click":
                Rtn = SeleniumActions.ActionClick(str, TestRun.Driver, Config.Time);
                break;

            case "SendKeys":
                Rtn = SeleniumActions.SendKeys(str, TestRun.Driver, Config.Time, val);
                break;

            case "Submit":
                Rtn = SeleniumActions.ActionSubmit(str, TestRun.Driver, Config.Time);
                break;

            case "Compare Text":
                var eText = SeleniumActions.GetText(str, TestRun.Driver, Config.Time);
                if (eText != Exp)
                {
                    log.Warn("Element Text : " + eText + " : Not equal to expected : " + Exp);
                }
                else
                {
                    log.Info("Text content :'" + eText + "' was expected");
                }
                Rtn = true;
                break;

            case "Hover":
                Rtn = SeleniumActions.ActionHover(str, TestRun.Driver, Config.Time);
                break;

            case "JavaClick":
                Rtn = SeleniumActions.JavaClick(str, TestRun.Driver, Config.Time);
                break;

            case "HttpPost":
                // Http Post is still under construction
                List <KeyValuePair <string, string> > pairstr = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>(TestRun.APIuser, TestRun.APIpass),
                    new KeyValuePair <string, string>("Content", val)
                };
                Rtn = APIFunctions.HttpPost(Config.BaseUrl + TestRun.URL, pairstr);
                break;

            case "GetText":
                string Textval = SeleniumActions.GetText(str, TestRun.Driver, Config.Time);
                UpdateStepValues(TestRun.TestStep, "TextValue", Textval);
                break;

            case "SelectList":
                Rtn = SeleniumActions.SelectFromList(str, TestRun.Driver, Config.Time, val);
                break;

            case "loadGrid":
                Rtn = SeleniumActions.LoadFromGrid(str, TestRun.Driver, Config.Time, val);
                break;

            case "Close":
                if (Config.Browser != "None")
                {
                    log.Info("Closing Browser!");
                    TestRun.Driver.Quit();
                }
                break;

            default:
            {
                log.Error("Unknown 'Action'.  Check spelling and case.");
                Rtn = false;
                break;
            }
            }


            return(Rtn);
        }