Beispiel #1
0
        static NewPayLoad GeneratePlatformActionPayload(IActPluginExecution ACT, Agent agent)
        {
            PlatformAction platformAction = ACT.GetAsPlatformAction();

            if (ACT is ActUIElement actUi)
            {
                if (actUi.ElementLocateBy == eLocateBy.POMElement)
                {
                    AddPOMLocators(ref platformAction, ref actUi, agent.ProjEnvironment, agent.BusinessFlow);
                }
            }

            // TODO: calculate VE ??!!

            NewPayLoad payload = new NewPayLoad("RunPlatformAction");

            payload.AddJSONValue <PlatformAction>(platformAction);
            payload.ClosePackage();

            // TODO: Process Valuefordriver!!!!

            return(payload);


            void AddPOMLocators(ref PlatformAction PlatformAction, ref ActUIElement UIElementAction, ProjEnvironment projEnvironment, BusinessFlow businessFlow)
            {
                Dictionary <string, string> Locators = new Dictionary <string, string>();


                List <string> Frames = new List <string>();

                string[]            pOMandElementGUIDs = UIElementAction.ElementLocateValue.ToString().Split('_');
                Guid                selectedPOMGUID    = new Guid(pOMandElementGUIDs[0]);
                ApplicationPOMModel currentPOM         = amdocs.ginger.GingerCoreNET.WorkSpace.Instance.SolutionRepository.GetRepositoryItemByGuid <ApplicationPOMModel>(selectedPOMGUID);

                if (currentPOM == null)
                {
                    UIElementAction.ExInfo = string.Format("Failed to find the mapped element Page Objects Model with GUID '{0}'", selectedPOMGUID.ToString());
                    return;
                }



                Guid        selectedPOMElementGUID = new Guid(pOMandElementGUIDs[1]);
                ElementInfo selectedPOMElement     = (ElementInfo)currentPOM.MappedUIElements.Where(z => z.Guid == selectedPOMElementGUID).FirstOrDefault();


                if (selectedPOMElement == null)
                {
                    UIElementAction.ExInfo = string.Format("Failed to find the mapped element with GUID '{0}' inside the Page Objects Model", selectedPOMElement.ToString());
                    return;
                }
                else
                {
                    List <NewPayLoad> switchframpayload = new List <NewPayLoad>();

                    if (selectedPOMElement.Path != null)
                    {
                        string[] spliter       = new string[] { "," };
                        string[] iframesPathes = selectedPOMElement.Path.Split(spliter, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string iframePath in iframesPathes)
                        {
                            Frames.Add(iframePath);
                        }
                    }

                    PlatformAction.InputParams.Add("Frames", Frames);


                    //adding all locators from POM

                    foreach (ElementLocator locator in selectedPOMElement.Locators.Where(x => x.Active == true).ToList())
                    {
                        string locateValue;
                        if (locator.IsAutoLearned)
                        {
                            locateValue = locator.LocateValue;
                        }
                        else
                        {
                            ElementLocator             evaluatedLocator = locator.CreateInstance() as ElementLocator;
                            GingerCore.ValueExpression VE = new GingerCore.ValueExpression(projEnvironment, businessFlow);
                            locateValue = VE.Calculate(evaluatedLocator.LocateValue);
                        }
                        Locators.Add(locator.LocateBy.ToString(), locateValue);
                    }



                    if (PlatformAction.InputParams.ContainsKey("Locators"))
                    {
                        PlatformAction.InputParams["Locators"] = Locators;
                    }
                    else
                    {
                        PlatformAction.InputParams.Add("Locators", Locators);
                    }
                }
            }
        }