Exemple #1
0
        public override string Script(IInterpreter interpreter)
        {
            //await page.click('.container > #mvcforum-nav > .nav > li > .auto-logon')
            string result = string.Empty;

            var content = MyAction.target.ToString();

            if (content.StartsWith("link="))
            {
                var script = string.Format("clickLink({0})"
                                           , interpreter.FormatSelector(MyAction.target));
                script = script + Environment.NewLine;

                result = script;
            }
            else
            {
                var newTarget = interpreter.FormatSelector(MyAction.target);
                var script    = string.Format("click('{0}')", newTarget);

                if (newTarget.StartsWith("{"))//json
                {
                    script = string.Format("click({0})", newTarget);
                }
                script = script + Environment.NewLine;
                result = script;
            }
            return(result);
        }
Exemple #2
0
        public override string Script(IInterpreter interpreter)
        {
            //await page.click('.container > #mvcforum-nav > .nav > li > .auto-logon')

            /*
             * Get value of element (element attribute 'value')
             *  [Katalon] storeValue : Target - element locator | Value - name of variable
             *  [Codecept] grabValueFrom : Param -element locator
             *
             *  [Katalon]
             *  <selenese>
             *          <command>storeValue</command>
             *          <target><![CDATA[id=some-locator]]></target>
             *          <value><![CDATA[var]]></value>
             *  </selenese>
             *
             *  [Codecept]
             *  let var = await I.grabValueFrom('#some-locator');
             */
            var script = string.Format("grabValueFrom({0}, '{1}')", interpreter.FormatSelector(MyAction.target), MyAction.value);

            script = script + Environment.NewLine;

            return(script);
        }
Exemple #3
0
        public override string Script(IInterpreter interpreter)
        {
            var script = string.Empty;
            //await page.click('.container > #mvcforum-nav > .nav > li > .auto-logon')
            var targetValue = MyAction.value;
            var content     = MyAction.target;

            if (targetValue.StartsWith("${"))
            {
                //default was get the value frm  I.MyGrabValue
                //targetValue = "I.MyGrabValue";
                // script = string.Format("MyGrabValue = await I.getMyGrabValue();I.fillField({0}, {1});", interpreter.FormatSelector(MyAction.target), targetValue);

                var variableName = targetValue.Replace("${", string.Empty);
                variableName = variableName.Replace("}", string.Empty);
                variableName = variableName.Trim();

                //say('ASSIGN'); {1} = {2};I.say('END_ASSIGN')
                script = string.Format("{0};I.fillField({1}, {2});", Keywords.useVariable, interpreter.FormatSelector(MyAction.target), variableName);
            }
            else
            {
                targetValue = MyAction.value;

                //TIP: variable declartion is handle by Modifier
                //script = string.Format("{0}{1} = {2};I.say('END_ASSIGN');I.fillField({2}, {1});", Keywords.declareVariable, variableName, interpreter.FormatSelector(MyAction.target));

                script = string.Format("fillField({0}, '{1}')", interpreter.FormatSelector(MyAction.target), targetValue);
            }

            script = script + Environment.NewLine;

            return(script);
        }
        public override string Script(IInterpreter interpreter)
        {
            //await page.click('.container > #mvcforum-nav > .nav > li > .auto-logon')
            var script = string.Format("fillField({0}, '{1}')", interpreter.FormatSelector(MyAction.target), MyAction.value);

            script = script + Environment.NewLine;

            return(script);
        }
Exemple #5
0
        public override string Script(IInterpreter interpreter)
        {
            //await page.click('.container > #mvcforum-nav > .nav > li > .auto-logon')
            string result = string.Empty;

            var content  = MyAction.target.ToString();
            var selValue = MyAction.value.Trim();
            //if (content.StartsWith("link="))
            //{
            //    var script = string.Format("clickLink({0})"
            //    , interpreter.FormatSelector(MyAction.target));
            //    script = script + Environment.NewLine;

            //    result = script;
            //}
            //else
            //{

            //}
            var newTarget = interpreter.FormatSelector(MyAction.target);

            var script = string.Empty;//string.Format("click('{0}')", newTarget);

            //label=Manager
            var split = selValue.Split('=');

            selValue = split.Last();                         //manager

            if (!selValue.StartsWith("'"))                   //json
            {
                selValue = string.Format("'{0}'", selValue); //'manager'
            }


            if (newTarget.StartsWith("{"))//json
            {
                script = string.Format("selectOption({0},{1})", newTarget, selValue);
            }
            else if (newTarget.StartsWith("'"))//json
            {
                script = string.Format("selectOption({0},{1})", newTarget, selValue);
            }
            else
            {
                script = string.Format("selectOption('{0}',{1})", newTarget, selValue);
            }
            script = script + Environment.NewLine;
            result = script;
            return(result);
        }
Exemple #6
0
        public override string Script(IInterpreter interpreter)
        {
            //string result = string.Empty;
            var    content         = MyAction.target.ToString();
            var    textContent     = MyAction.value;
            string grabAsyncParams = "";
            string target          = interpreter.FormatSelector(MyAction.target);

            //#0#Write issued company-owned equipment, devices, and tools here#0#172###578Delay3
            //#0#Write issued company-owned equipment, devices, and tools here#0#172###578
            var delimitter = Keywords.NoDelimiter;

            string[] splitDelay = textContent
                                  .Split(new string[] { delimitter }, StringSplitOptions.None);

            //#0#Write issued company-owned equipment, devices, and tools here#0#172###578
            var    firstPart = splitDelay.First();
            string result    = string.Empty;

            if (textContent.Contains(Keywords.GrabMultiDelimiter))
            {
                grabAsyncParams = ", true";
            }

            target += grabAsyncParams;

            if (string.IsNullOrEmpty(textContent) || !textContent.Contains("#1#"))
            {
                if (content.StartsWith("link="))
                {
                    var script = string.Format("grabAsync({0})", target);
                    script += Environment.NewLine;
                    result  = script;
                }
                else
                {
                    var script = string.Empty;//string.Format("click('{0}')", target);
                    var prefix = string.Format("{0};MyGrabValue = await I.", @"say('MyGrabValue:')");

                    if (target.StartsWith("{"))//json
                    {
                        //alternately use mouseClickXpathToGrabValue
                        script = string.Format("grabAsync({0})", target);
                    }
                    else if (target.StartsWith("'"))//json
                    {
                        script = string.Format("grabAsync({0})", target);
                    }
                    else if (target.StartsWith("concat("))//json
                    {
                        script = string.Format("grabAsync({0})", target);
                    }
                    else if (target.StartsWith("grabAsync("))//json
                    {
                        script = string.Format("grabAsync({0})", target);
                    }
                    else
                    {
                        script = string.Format("grabAsync('{0}')", target);
                    }
                    script += Environment.NewLine;
                    result  = prefix + script;
                }
            }
            else
            {
                //get the text value in #0#
                delimitter = "#1#";
                string[] splitScript = textContent.Split(new string[] { delimitter }, StringSplitOptions.None);

                var xyPart = splitScript.Last();

                delimitter = Keywords.NoDelimiter;
                splitDelay = xyPart
                             .Split(new string[] { delimitter }, StringSplitOptions.None);

                var resultScript = splitDelay.First();// + "Delay1";

                var script1 = string.Format("mouseClickXYToGrabValue('{0}');", resultScript);
                result = script1;
            }
            return(result);
        }
Exemple #7
0
        public override string Script(IInterpreter interpreter)
        {
            //await page.click('.container > #mvcforum-nav > .nav > li > .auto-logon')
            string result  = string.Empty;
            string locator = string.Empty;

            var content = MyAction.target.ToString();

            //if (content.StartsWith("link="))
            //{
            //    locator = interpreter.FormatSelector(MyAction.target);
            //    var script = string.Format("waitForElement({0})", locator);
            //    //script = script + Environment.NewLine;

            //    result = script;
            //}
            //else
            //{
            //    string newTarget = interpreter.FormatSelector(MyAction.target);

            //    locator = string.Format("'{0}'",newTarget);
            //    //see('submit')
            //    var script = string.Format("waitForElement({0})", locator);

            //    if (newTarget.StartsWith("{"))//json
            //    {
            //        locator = newTarget;
            //        script = string.Format("waitForElement({0})", newTarget);
            //    }
            //    //script = script + Environment.NewLine;
            //    result = script;
            //}


            if (content.StartsWith("link="))
            {
                var script = string.Format("see({0})"
                                           , interpreter.FormatSelector(MyAction.target));
                script = script + Environment.NewLine;

                result = script;
            }
            else
            {
                var newTarget = interpreter.FormatSelector(MyAction.target);

                var script = string.Empty;     //string.Format("click('{0}')", newTarget);

                if (newTarget.StartsWith("{")) //json
                {
                    script = string.Format("waitForElement({0})", newTarget);
                }
                else if (newTarget.StartsWith("'"))//json
                {
                    script = string.Format("waitForElement({0})", newTarget);
                }
                else if (newTarget.StartsWith("concat("))//json
                {
                    script = string.Format("waitForElement({0})", newTarget);
                }
                //else if (newTarget.StartsWith("waitForElement("))//json
                //{
                //    script = string.Format("see({0})", newTarget);
                //}


                else
                {
                    script = string.Format("see('{0}')", newTarget);
                }
                script = script + Environment.NewLine;
                result = script;
            }


            string finalResult = string.Format("{0};MyGrabValue = await I.grabAsync({1});", result.Trim(), interpreter.FormatSelector(MyAction.target));//locator.Trim());

            finalResult = finalResult + Environment.NewLine;
            return(finalResult);
        }
Exemple #8
0
        public override string Script(IInterpreter interpreter)
        {
            //await page.click('.container > #mvcforum-nav > .nav > li > .auto-logon')
            string result = string.Empty;

            var content = MyAction.target.ToString();

            var textContent = MyAction.value;

            if (string.IsNullOrEmpty(textContent) || !textContent.Contains("#1#"))
            {
                if (content.StartsWith("link="))
                {
                    var script = string.Format("clickLink({0})"
                                               , interpreter.FormatSelector(MyAction.target));
                    script = script + Environment.NewLine;

                    result = script;
                }
                else
                {
                    var newTarget = interpreter.FormatSelector(MyAction.target);

                    var script = string.Empty;     //string.Format("click('{0}')", newTarget);

                    if (newTarget.StartsWith("{")) //json
                    {
                        script = string.Format("click({0})", newTarget);
                    }
                    else if (newTarget.StartsWith("'"))//json
                    {
                        script = string.Format("click({0})", newTarget);
                    }
                    else if (newTarget.StartsWith("concat("))//json
                    {
                        script = string.Format("click({0})", newTarget);
                    }
                    else if (newTarget.StartsWith("click("))//json
                    {
                        script = string.Format("click({0})", newTarget);
                    }
                    else
                    {
                        script = string.Format("click('{0}')", newTarget);
                    }
                    script = script + Environment.NewLine;
                    result = script;
                }
            }//no textContent
            else if (textContent.Contains("#1#")) //default use text in button like click('Login');
            {
                string   delimitter  = "#1#";
                string[] splitScript = textContent.Split(new string[] { delimitter }, StringSplitOptions.None);

                if (textContent.StartsWith("#0#"))
                {
                    //"mouseClick('Price high to low#0#1030###346Delay10')"

                    delimitter = "Delay";
                    string[] splitDelay = splitScript.Last()
                                          .Split(new string[] { delimitter }, StringSplitOptions.None);

                    var script1 = string.Format("mouseClick('{0}');I.wait({1})", splitDelay.First(), splitDelay.Last());
                    result = script1;
                }
                else
                {
                    delimitter = "#";
                    string[] splitScript2 = splitScript.Last().Split(new string[] { delimitter }, StringSplitOptions.None);

                    var script2 = string.Format("click('{0}')", splitScript2.First());

                    result = script2;
                }
            }
            return(result);
        }
Exemple #9
0
        public override string Script(IInterpreter interpreter)
        {
            //await page.click('.container > #mvcforum-nav > .nav > li > .auto-logon')
            string result = string.Empty;

            var content     = MyAction.target.ToString();
            var textContent = MyAction.value;

            if (textContent.Contains(Keywords.ClickAndEndDelimiter))//("Delay3_END"))// do click and type
            {
                return(ScriptClickToEnd(interpreter));
            }

            else if (string.IsNullOrEmpty(textContent) || !textContent.Contains("#1#"))
            {
                if (content.StartsWith("link="))
                {
                    var script = string.Format("clickLink({0})"
                                               , interpreter.FormatSelector(MyAction.target));
                    script = script + Environment.NewLine;

                    result = script;
                }
                else
                {
                    var newTarget = interpreter.FormatSelector(MyAction.target);

                    var script = string.Empty;     //string.Format("click('{0}')", newTarget);

                    if (newTarget.StartsWith("{")) //json
                    {
                        script = string.Format("click({0})", newTarget);
                    }
                    else if (newTarget.StartsWith("'"))//json
                    {
                        script = string.Format("click({0})", newTarget);
                    }
                    else if (newTarget.StartsWith("concat("))//json
                    {
                        script = string.Format("click({0})", newTarget);
                    }
                    else if (newTarget.StartsWith("click("))//json
                    {
                        script = string.Format("click({0})", newTarget);
                    }
                    else
                    {
                        script = string.Format("click('{0}')", newTarget);
                    }
                    script = script + Environment.NewLine;
                    result = script;
                }
            }//no textContent
            else if (textContent.Contains("#1#")) //default use text in button like click('Login');
            {
                string   delimitter  = "#1#";
                string[] splitScript = textContent.Split(new string[] { delimitter }, StringSplitOptions.None);

                var xyPart = splitScript.Last();

                if (textContent.StartsWith("#0#"))
                {
                    //"mouseClick('Price high to low#0#1030###346Delay10')"
                    if (xyPart.Contains(Keywords.JustTypeOnlyDelimiter))//("Delay3_"))// do click and type
                    {
                        delimitter = Keywords.JustTypeOnlyDelimiter;
                        string[] splitDelay = xyPart
                                              .Split(new string[] { delimitter }, StringSplitOptions.None);


                        var script1 = string.Format("sendCharacter('{0}');", splitDelay.Last());
                        result = script1;
                    }
                    else if (xyPart.Contains(Keywords.TypeAndTabDelimiter))//("Delay3_"))// do click and type
                    {
                        delimitter = Keywords.TypeAndTabDelimiter;
                        string[] splitDelay = xyPart
                                              .Split(new string[] { delimitter }, StringSplitOptions.None);
                        var scriptTab = string.Format("I.pressKey('{0}');", "Tab");

                        var script1 = string.Format("sendCharacter('{0}');", splitDelay.Last()) + scriptTab;
                        result = script1;
                    }
                    else if (xyPart.Contains(Keywords.clickAndTypeDelimiter))//("Delay3_"))// do click and type
                    {
                        delimitter = Keywords.clickAndTypeDelimiter;
                        string[] splitDelay = xyPart
                                              .Split(new string[] { delimitter }, StringSplitOptions.None);

                        var script1 = string.Format("mouseClick('{0}');I.wait(1);I.sendCharacter('{1}');", splitDelay.First(), splitDelay.Last());
                        result = script1;

                        //todo ADD modifier to handle variable input assignment var like...
                        //I.say('step#2');I.say('DECLARE');var input_1_ = '*****@*****.**';I.waitForElement('[id="usernamebox"]',45);I.retry({ retries: 3, maxTimeout: 3000 }).fillField({id:'usernamebox'}, input_1_);I.wait(1);
                    }
                    else
                    {
                        delimitter = "Delay";
                        string[] splitDelay = xyPart
                                              .Split(new string[] { delimitter }, StringSplitOptions.None);

                        var script1 = string.Format("mouseClick('{0}');I.wait({1})", splitDelay.First(), splitDelay.Last());
                        result = script1;
                    }
                }
                else
                {
                    delimitter = "#";
                    string[] splitScript2 = splitScript.Last().Split(new string[] { delimitter }, StringSplitOptions.None);

                    var script2 = string.Format("click('{0}')", splitScript2.First());

                    result = script2;
                }
            }
            return(result);
        }