Example #1
0
        public void FlowcontrolTest_WithBFCreateCopy()
        {
            //Arrange
            BusinessFlow bf = new BusinessFlow("Test");

            Activity activity = new Activity();

            activity.ActivityName = "Login";

            ActUIElement actGotoURL = new ActUIElement();

            actGotoURL.Description = "Launch";

            activity.Acts.Add(actGotoURL);

            Activity activity2 = new Activity();

            activity2.ActivityName = "Test";

            ActDummy act2 = new ActDummy();

            act2.Description = "WaitForApp";

            activity.Acts.Add(act2);

            FlowControl flowControl = new FlowControl();

            flowControl.Active            = true;
            flowControl.Condition         = "1=1";
            flowControl.FlowControlAction = eFlowControlAction.GoToActivity;
            flowControl.Value             = activity2.Guid + flowControl.GUID_NAME_SEPERATOR + activity2.ItemName;

            FlowControl flowControl2 = new FlowControl();

            flowControl2.Active            = true;
            flowControl2.Condition         = "2=2";
            flowControl2.FlowControlAction = eFlowControlAction.GoToAction;
            flowControl2.Value             = act2.Guid + flowControl.GUID_NAME_SEPERATOR + act2.ItemName;


            actGotoURL.FlowControls.Add(flowControl);
            actGotoURL.FlowControls.Add(flowControl2);

            bf.Activities.RemoveAt(0);
            bf.Activities.Add(activity);
            bf.Activities.Add(activity2);

            activity2.ActivityName = "Test_New";
            bf.RepositorySerializer.SaveToFile(bf, TestResources.GetTempFile("BF.xml"));

            //Act
            BusinessFlow bfCopy = (BusinessFlow)bf.CreateInstance();

            Guid newGuidOfActivity2 = bfCopy.Activities.Where(x => x.ItemName == "Test_New").FirstOrDefault().Guid;

            Guid newGuidOfAct2 = bfCopy.Activities[0].Acts.Where(x => x.ItemName == "WaitForApp").FirstOrDefault().Guid;


            //Assert
            Assert.AreEqual(bfCopy.Activities[0].Acts[0].FlowControls[1].GetGuidFromValue(), newGuidOfAct2);
            Assert.AreEqual(bfCopy.Activities[0].Acts[0].FlowControls[0].GetGuidFromValue(), newGuidOfActivity2);
        }
Example #2
0
        private Act GetNewActionForWeb()
        {
            bool uIElementTypeAssigned = false;

            ActUIElement NewActUIElement = GetNewUIElementFromAutoMapper();

            ActBrowserElement NewActBrowserElement = GetNewBrowserElementFromAutoMapper();

            Type currentType = GetActionTypeByElementActionName(GenElementAction);

            if (currentType == typeof(ActBrowserElement))
            {
                switch (GenElementAction)
                {
                case eGenElementAction.Back:
                    NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.NavigateBack;
                    break;

                case eGenElementAction.CloseBrowser:
                    NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.Close;
                    break;

                case eGenElementAction.StartBrowser:
                    NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.InitializeBrowser;
                    break;

                default:
                    try
                    {
                        NewActBrowserElement.ControlAction = (ActBrowserElement.eControlAction)System.Enum.Parse(typeof(ActBrowserElement.eControlAction), GenElementAction.ToString());
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Error occurred while mapping the operation to action while conversion", ex);
                        throw;
                    }
                    break;
                }
            }
            else if (currentType == typeof(ActUIElement))
            {
                switch (GenElementAction)
                {
                case eGenElementAction.Click:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.JavaScriptClick;
                    break;

                case eGenElementAction.RightClick:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.MouseRightClick;
                    break;

                case eGenElementAction.Visible:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.IsVisible;
                    break;

                case eGenElementAction.SelectFromListScr:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SelectByIndex;
                    NewActUIElement.ElementType   = eElementType.List;
                    uIElementTypeAssigned         = true;
                    break;

                case eGenElementAction.AsyncSelectFromDropDownByIndex:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SelectByIndex;
                    NewActUIElement.ElementType   = eElementType.ComboBox;
                    break;

                case eGenElementAction.KeyboardInput:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SendKeys;
                    break;

                case eGenElementAction.KeyType:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SetText;
                    break;

                case eGenElementAction.SelectFromDropDown:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SelectByText;
                    NewActUIElement.ElementType   = eElementType.ComboBox;
                    uIElementTypeAssigned         = true;
                    break;

                case eGenElementAction.GetInnerText:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.GetText;
                    break;

                case eGenElementAction.GetCustomAttribute:
                case eGenElementAction.GetElementAttributeValue:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.GetAttrValue;
                    break;

                case eGenElementAction.BatchClicks:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.MultiClicks;
                    break;

                case eGenElementAction.BatchSetValues:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.MultiSetValue;
                    break;

                case eGenElementAction.SimpleClick:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.Click;
                    break;

                case eGenElementAction.Disabled:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.IsDisabled;
                    break;

                case eGenElementAction.Enabled:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.IsEnabled;
                    break;

                case eGenElementAction.GetNumberOfElements:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.GetItemCount;
                    break;

                case eGenElementAction.XYClick:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.ClickXY;
                    break;

                case eGenElementAction.Focus:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SetFocus;
                    break;

                case eGenElementAction.RunJavaScript:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.RunJavaScript;
                    break;

                case eGenElementAction.SetAttributeUsingJs:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.RunJavaScript;
                    break;

                default:
                    try
                    {
                        NewActUIElement.ElementAction = (ActUIElement.eElementAction)System.Enum.Parse(typeof(ActUIElement.eElementAction), GenElementAction.ToString());
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Error occurred while mapping the operation to action while conversion", ex);
                        throw;
                    }
                    break;
                }
            }

            if (currentType == typeof(ActUIElement))
            {
                NewActUIElement.ElementLocateBy = (eLocateBy)((int)this.LocateBy);
                if (!string.IsNullOrEmpty(this.LocateValue))
                {
                    if (GenElementAction == eGenElementAction.SetAttributeUsingJs)
                    {
                        NewActUIElement.Value = string.Format("arguments[0].{0}", this.Value);
                    }
                    else
                    {
                        NewActUIElement.ElementLocateValue = String.Copy(this.LocateValue);
                    }
                }

                if (!uIElementTypeAssigned)
                {
                    NewActUIElement.ElementType = eElementType.Unknown;
                }
                if (!NewActUIElement.Platforms.Contains(this.Platform))
                {
                    NewActUIElement.Platform = ePlatformType.Web; // ??? to check
                }

                NewActUIElement.AddOrUpdateInputParamValue(ActUIElement.Fields.ValueToSelect, this.GetInputParamValue("Value"));
                return(NewActUIElement);
            }

            if (currentType == typeof(ActBrowserElement))
            {
                return(NewActBrowserElement);
            }
            return(null);
        }
 public abstract string ClickAndValidteHandler(object element, ActUIElement action);
Example #4
0
        Act IObsoleteAction.GetNewAction()
        {
            ActUIElement NewAct = new ActUIElement();

            NewAct.CopyInfoFrom(this);
            NewAct.Description = "[New] " + Description;
            NewAct.ElementType = eElementType.Unknown;

            switch (GenElementAction)
            {
            case eGenElementAction.Click:
                NewAct.ElementAction = ActUIElement.eElementAction.Click;
                break;

            case eGenElementAction.GetValue:
                NewAct.ElementAction = ActUIElement.eElementAction.GetValue;
                break;

            case eGenElementAction.SetValue:
                NewAct.ElementAction = ActUIElement.eElementAction.SetValue;
                break;

            default:
                throw new Exception("Converter error, missing Action translator for - " + GenElementAction);
            }

            //TODO: move to Act.cs so can be used by other converter
            switch (LocateBy)
            {
            case eLocateBy.ByID:
                if (Platform == ePlatformType.AndroidDevice)
                {
                    NewAct.LocateBy = eLocateBy.ByResourceID;
                }
                else
                {
                    NewAct.LocateBy = eLocateBy.ByID;
                }
                break;

            case eLocateBy.ByXPath:
                NewAct.LocateBy = eLocateBy.ByXPath;
                break;

            case eLocateBy.ByCSS:
                NewAct.LocateBy = eLocateBy.ByCSS;
                break;

            case eLocateBy.ByXY:
                NewAct.LocateBy = eLocateBy.ByXY;
                break;

            default:
                throw new Exception("Converter error, missing LocateBy translator for - " + LocateBy);
                //TODO: add all the rest
            }

            NewAct.ElementLocateValue = this.LocateValue;

            return(NewAct);
        }
        public override Act GetPlatformActionByElementInfo(ElementInfo elementInfo, ElementActionCongifuration actConfig)
        {
            var pomExcutionUtil = new POMExecutionUtils();
            Act elementAction   = null;

            if (elementInfo != null)
            {
                List <ActUIElement.eElementAction> elementTypeOperations;
                if (elementInfo.GetType().Equals(typeof(HTMLElementInfo)))
                {
                    elementTypeOperations = GetPlatformWidgetsUIActionsList(elementInfo.ElementTypeEnum);
                }
                else
                {
                    elementTypeOperations = GetPlatformUIElementActionsList(elementInfo.ElementTypeEnum);
                }
                if (actConfig != null)
                {
                    if (string.IsNullOrWhiteSpace(actConfig.Operation))
                    {
                        actConfig.Operation = GetDefaultElementOperation(elementInfo.ElementTypeEnum);
                    }
                }
                if ((elementTypeOperations != null) && (elementTypeOperations.Count > 0))
                {
                    elementAction = new ActUIElement()
                    {
                        Description        = string.IsNullOrWhiteSpace(actConfig.Description) ? "UI Element Action : " + actConfig.Operation + " - " + elementInfo.ItemName : actConfig.Description,
                        ElementAction      = (ActUIElement.eElementAction)System.Enum.Parse(typeof(ActUIElement.eElementAction), actConfig.Operation),
                        ElementLocateValue = actConfig.LocateValue,
                        Value = actConfig.ElementValue
                    };

                    if (elementInfo.ElementTypeEnum.Equals(eElementType.Table))
                    {
                        elementAction.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnValue, actConfig.WhereColumnValue);
                        elementAction.GetOrCreateInputParam(ActUIElement.Fields.LocateRowType, actConfig.LocateRowType);
                        elementAction.GetOrCreateInputParam(ActUIElement.Fields.LocateRowValue, actConfig.RowValue);
                        elementAction.GetOrCreateInputParam(ActUIElement.Fields.ColSelectorValue, actConfig.ColSelectorValue);
                        elementAction.GetOrCreateInputParam(ActUIElement.Fields.LocateColTitle, actConfig.LocateColTitle);
                        elementAction.GetOrCreateInputParam(ActUIElement.Fields.ControlAction, actConfig.ControlAction);
                    }
                    if (elementInfo.GetType().Equals(typeof(HTMLElementInfo)))
                    {
                        elementAction.GetOrCreateInputParam(ActUIElement.Fields.IsWidgetsElement, "true");
                    }
                    pomExcutionUtil.SetPOMProperties(elementAction, elementInfo, actConfig);
                }
            }
            else
            {
                elementAction = new ActUIElement()
                {
                    Description        = string.IsNullOrWhiteSpace(actConfig.Description) ? "UI Element Action : " + actConfig.Operation + " - " + elementInfo.ItemName : actConfig.Description,
                    ElementLocateBy    = (eLocateBy)System.Enum.Parse(typeof(eLocateBy), Convert.ToString(actConfig.LocateBy)),
                    ElementAction      = (ActUIElement.eElementAction)System.Enum.Parse(typeof(ActUIElement.eElementAction), actConfig.Operation),
                    ElementLocateValue = actConfig.LocateValue,
                    ElementType        = (eElementType)System.Enum.Parse(typeof(eElementType), Convert.ToString(actConfig.Type)),
                    Value = actConfig.ElementValue
                };
            }
            return(elementAction);
        }
 public POMExecutionUtils(Act act)
 {
     mAct = (ActUIElement)act;
 }
Example #7
0
        Act IObsoleteAction.GetNewAction()
        {
            AutoMapper.MapperConfiguration mapConfig = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap <Act, ActUIElement>(); });
            ActUIElement newAct = mapConfig.CreateMapper().Map <Act, ActUIElement>(this);

            newAct.ElementType = eElementType.Unknown;

            switch (this.ActDropDownListAction)
            {
            case eActDropDownListAction.SetSelectedValueByValue:
                newAct.ElementAction = ActUIElement.eElementAction.SetSelectedValueByValue;
                break;

            case eActDropDownListAction.SetSelectedValueByIndex:
                newAct.ElementAction = ActUIElement.eElementAction.SetSelectedValueByIndex;
                break;

            case eActDropDownListAction.SetSelectedValueByText:
                newAct.ElementAction = ActUIElement.eElementAction.SetSelectedValueByText;
                break;

            case eActDropDownListAction.ClearSelectedValue:
                newAct.ElementAction = ActUIElement.eElementAction.ClearSelectedValue;
                break;

            case eActDropDownListAction.SetFocus:
                newAct.ElementAction = ActUIElement.eElementAction.SetFocus;
                break;

            case eActDropDownListAction.GetValidValues:
                newAct.ElementAction = ActUIElement.eElementAction.GetValidValues;
                break;

            case eActDropDownListAction.GetSelectedValue:
                newAct.ElementAction = ActUIElement.eElementAction.GetSelectedValue;
                break;

            case eActDropDownListAction.IsPrepopulated:
                newAct.ElementAction = ActUIElement.eElementAction.IsPrepopulated;
                break;

            case eActDropDownListAction.GetFont:
                newAct.ElementAction = ActUIElement.eElementAction.GetFont;
                break;

            case eActDropDownListAction.GetWidth:
                newAct.ElementAction = ActUIElement.eElementAction.GetWidth;
                break;

            case eActDropDownListAction.GetHeight:
                newAct.ElementAction = ActUIElement.eElementAction.GetHeight;
                break;

            case eActDropDownListAction.GetStyle:
                newAct.ElementAction = ActUIElement.eElementAction.GetStyle;
                break;

            default:
                newAct.ElementAction = ActUIElement.eElementAction.Unknown;
                break;
            }

            newAct.ElementLocateBy    = (eLocateBy)((int)this.LocateBy);
            newAct.ElementLocateValue = String.Copy(this.LocateValue);
            newAct.ElementType        = eElementType.ComboBox;
            newAct.Active             = true;

            return(newAct);
        }
        private void TestButton_Click(object sender, RoutedEventArgs e)
        {
            TestStatusTextBlock.Text = "Executing";
            //TODO: do events?
            Act act;

            //We came from ActionEditPage
            if (mAction != null)
            {
                act = (Act)((Act)(mAction)).CreateCopy();
            }
            else
            {
                act = (Act)((Act)(mActions.CurrentItem)).CreateCopy();
            }

            // Copy from the selected Locator
            ElementLocator EL = (ElementLocator)mLocators.CurrentItem;

            act.AddNewReturnParams = true;
            act.Active             = true;
            if ((mActions.CurrentItem).GetType() == typeof(ActUIElement))
            {
                ActUIElement aaa   = (ActUIElement)mActions.CurrentItem;
                ActUIElement actUI = (ActUIElement)act;
                actUI.ElementLocateBy    = EL.LocateBy;
                actUI.ElementLocateValue = EL.LocateValue;
                actUI.Value = ValueTextBox.Text;
                actUI.GetOrCreateInputParam(ActUIElement.Fields.ControlActionValue, ValueTextBox.Text);
                actUI.GetOrCreateInputParam(ActUIElement.Fields.ControlAction, aaa.GetInputParamValue(ActUIElement.Fields.ControlAction));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereColSelector, aaa.GetInputParamValue(ActUIElement.Fields.WhereColSelector));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnTitle, aaa.GetInputParamValue(ActUIElement.Fields.WhereColumnTitle));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnValue, aaa.GetInputParamValue(ActUIElement.Fields.WhereColumnValue));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereOperator, aaa.GetInputParamValue(ActUIElement.Fields.WhereOperator));
                actUI.GetOrCreateInputParam(ActUIElement.Fields.WhereProperty, aaa.GetInputParamValue(ActUIElement.Fields.WhereProperty));
            }
            else
            {
                act.LocateBy = EL.LocateBy;
                act.LocateValueCalculated = EL.LocateValue;
                act.Value = ValueTextBox.Text;
            }

            App.AutomateTabGingerRunner.PrepActionVE(act);
            ApplicationAgent ag = App.AutomateTabGingerRunner.ApplicationAgents.Where(x => x.AppName == App.BusinessFlow.CurrentActivity.TargetApplication).FirstOrDefault();

            if (ag != null)
            {
                App.AutomateTabGingerRunner.ExecutionLogger.Configuration.ExecutionLoggerAutomationTabContext = ExecutionLoggerConfiguration.AutomationTabContext.ActionRun;
                ag.Agent.RunAction(act);
            }

            TestStatusTextBlock.Text = string.Empty;
            if (act.Status != null)
            {
                TestStatusTextBlock.Text += act.Status + System.Environment.NewLine;
            }
            if (string.IsNullOrEmpty(act.Error) == false)
            {
                TestStatusTextBlock.Text += act.Error + System.Environment.NewLine;
            }
            if (string.IsNullOrEmpty(act.ExInfo) == false)
            {
                TestStatusTextBlock.Text += act.ExInfo + System.Environment.NewLine;
            }

            string retval = GetAllRetVals(act);

            if (retval != null)
            {
                TestStatusTextBlock.Text += retval + System.Environment.NewLine;
            }
        }
Example #9
0
        public override ObservableList <Act> GetPlatformElementActions(ElementInfo elementInfo)
        {
            if (elementInfo.GetType() == typeof(HTMLElementInfo))
            {
                return(GetWidgetUIElementList(elementInfo));
            }

            ObservableList <Act> UIElementsActionsList = new ObservableList <Act>();
            eElementType         elementType           = GetElementType(elementInfo.ElementType);

            if (elementType.Equals(eElementType.Table))
            {
                //get all action list supported to table
                var tableActionList = new[] { ActUIElement.eElementAction.TableCellAction, ActUIElement.eElementAction.TableAction, ActUIElement.eElementAction.TableRowAction }
                .SelectMany(action => GetTableControlActions(action))
                .ToList();
                foreach (var action in tableActionList)
                {
                    var elementAction = ActUIElement.eElementAction.TableCellAction;

                    if (action.Equals(ActUIElement.eTableAction.GetRowCount) || action.Equals(ActUIElement.eTableAction.SelectAllRows))
                    {
                        elementAction = ActUIElement.eElementAction.TableAction;
                    }
                    else if (action.Equals(ActUIElement.eTableAction.GetSelectedRow) || action.Equals(ActUIElement.eTableAction.ActivateRow))
                    {
                        elementAction = ActUIElement.eElementAction.TableRowAction;
                    }

                    var actUITableAction = new ActUIElement()
                    {
                        Description   = action + " : " + elementInfo.ElementTitle,
                        ElementType   = eElementType.Table,
                        ElementAction = elementAction,
                    };
                    actUITableAction.GetOrCreateInputParam(ActUIElement.Fields.ControlAction, action.ToString());
                    actUITableAction.GetOrCreateInputParam(ActUIElement.Fields.WaitforIdle, ActUIElement.eWaitForIdle.Medium.ToString());
                    if (!action.Equals(ActUIElement.eElementAction.TableAction))
                    {
                        actUITableAction.GetOrCreateInputParam(ActUIElement.Fields.RowSelectorRadioParam, "RowNum");
                        actUITableAction.GetOrCreateInputParam(ActUIElement.Fields.LocateRowType, "Row Number");
                        actUITableAction.GetOrCreateInputParam(ActUIElement.Fields.LocateRowValue, "0");

                        actUITableAction.GetOrCreateInputParam(ActUIElement.Fields.ColSelectorValue, ActUIElement.eTableElementRunColSelectorValue.ColNum.ToString());
                        actUITableAction.GetOrCreateInputParam(ActUIElement.Fields.LocateColTitle, "0");
                    }
                    UIElementsActionsList.Add(actUITableAction);
                }
            }
            else
            {
                var actionList = GetPlatformUIElementActionsList(elementType);

                if (actionList.Count > 0)
                {
                    foreach (var action in actionList)
                    {
                        UIElementsActionsList.Add(CreateUIElementAction(elementInfo, elementType, action));
                    }
                }
            }

            return(UIElementsActionsList);
        }
Example #10
0
        public void MapASCFActionItems(String locateValue, ActUIElement newAct)
        {
            switch (LocateBy)
            {
            case eLocateBy.ByXPath:
                newAct.ElementLocateBy = eLocateBy.ByXPath;
                break;

            case eLocateBy.ByName:
                newAct.ElementLocateBy = eLocateBy.ByName;
                break;

            case eLocateBy.ByValue:
                newAct.ElementLocateBy = eLocateBy.ByValue;
                break;

            case eLocateBy.ByText:
                newAct.ElementLocateBy = eLocateBy.ByText;
                break;

            case eLocateBy.ByTitle:
                newAct.ElementLocateBy = eLocateBy.ByTitle;
                break;

            default:
                newAct.ElementLocateBy = eLocateBy.Unknown;
                break;
            }

            if (!String.IsNullOrEmpty(locateValue))
            {
                // check if the current action is a garbage action or not
                if (!string.IsNullOrEmpty(this.LocateValue) && this.LocateValue.Contains("com.amdocs.crm.workspace.OpenWindows:OpenedWindowsTree"))
                {
                    newAct.Active      = false;
                    newAct.Description = "Please remove this action - " + this.Description;
                    return;
                }

                int slash = locateValue.IndexOf("/");
                int colon = locateValue.IndexOf(":");
                if (slash == -1)
                {
                    newAct.Value = this.Value;
                    if (locateValue.Count(x => x == ':') > 1)
                    {
                        locateValue = locateValue.Substring(locateValue.LastIndexOf(':') + 1);
                    }
                    else
                    {
                        locateValue = locateValue.Substring(colon + 1);
                    }

                    newAct.ElementLocateValue = locateValue;

                    newAct.ElementType = eElementType.Unknown;

                    foreach (ActUIElement.eElementAction x in Enum.GetValues(typeof(ActUIElement.eElementAction)))
                    {
                        if (this.ControlAction.ToString().Equals(x.ToString()))
                        {
                            newAct.ElementAction = x;
                            return;
                        }
                        else
                        {
                            // if old action is not supported by ACTUIElement, for example, GetControlProperty
                            newAct.ElementAction = ActUIElement.eElementAction.Unknown;
                        }
                    }
                }
                else
                {
                    if (checkWhetherTreeElement(locateValue, newAct))
                    {
                        return;
                    }
                    newAct.ElementType     = eElementType.Table;
                    newAct.ElementAction   = ActUIElement.eElementAction.TableCellAction;
                    newAct.ElementLocateBy = eLocateBy.ByContainerName;
                    // Parse the Column Selector
                    int col = locateValue.IndexOf(":", slash);

                    string colSelector = (slash == locateValue.Length - 1) ? "" : locateValue.Substring(slash + 1, (locateValue.Length - 1) - (slash + 1)).Replace(@":", string.Empty);
                    colSelector = colSelector.Trim();
                    int colNum = 0;
                    if (colSelector.All(char.IsDigit))
                    {
                        colNum = Convert.ToInt32(colSelector);
                        newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.ColSelectorValue, ActUIElement.eTableElementRunColSelectorValue.ColNum.ToString());
                        newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateColTitle, colNum.ToString());
                    }
                    else
                    {
                        if (!String.IsNullOrEmpty(colSelector))
                        {
                            if (colSelector.IndexOf("[") == -1)
                            {
                                newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.ColSelectorValue, ActUIElement.eTableElementRunColSelectorValue.ColTitle.ToString());
                                newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateColTitle, colSelector);
                            }
                            else
                            {
                                if (colSelector.StartsWith("[name="))
                                {
                                    newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.ColSelectorValue, ActUIElement.eTableElementRunColSelectorValue.ColName.ToString());
                                }
                                else if (colSelector.StartsWith("[title="))
                                {
                                    newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.ColSelectorValue, ActUIElement.eTableElementRunColSelectorValue.ColTitle.ToString());
                                }
                                else if (colSelector.StartsWith("[number="))
                                {
                                    newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.ColSelectorValue, ActUIElement.eTableElementRunColSelectorValue.ColNum.ToString());
                                }
                                newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateColTitle, colSelector.Split('\"')[1]);
                            }
                        }
                    }

                    // Parse the Row Selector
                    string rowSelector = locateValue.Substring(col + 1);
                    if (!String.IsNullOrEmpty(rowSelector))
                    {
                        if (rowSelector.StartsWith("[number="))
                        {
                            string row = rowSelector.Split('\"')[1];
                            if ("random".Equals(row))
                            {
                                newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.RowSelectorRadioParam, ActUIElement.eRadioButtonValueType.AnyRow.ToString());
                            }
                            else
                            {
                                newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.RowSelectorRadioParam, ActUIElement.eRadioButtonValueType.RowNum.ToString());
                                newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateRowValue, row);
                            }
                        }
                        else if (rowSelector.All(char.IsDigit))
                        {
                            int rowNum = Convert.ToInt32(rowSelector);
                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.RowSelectorRadioParam, ActUIElement.eRadioButtonValueType.RowNum.ToString());
                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateRowValue, rowNum.ToString());
                        }
                        else if (rowSelector.Equals("random"))
                        {
                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.RowSelectorRadioParam, ActUIElement.eRadioButtonValueType.AnyRow.ToString());
                        }
                        else
                        {
                            if (rowSelector == string.Empty)
                            {
                                throw new Exception("Malformed row selector");
                            }
                            string[] conditions = rowSelector.Split(new string[] { "]]" }, StringSplitOptions.None);
                            foreach (string condition in conditions)
                            {
                                string cond = !String.IsNullOrEmpty(condition) ? condition.Trim() : "";
                                if (String.IsNullOrEmpty(cond.ToString()) || cond[0] == ']')
                                {
                                    break;
                                }
                                if (cond.IndexOf(":") != -1)
                                {
                                    colon = cond.IndexOf(":", 1);
                                    string rowColSelector      = cond.Substring(cond.LastIndexOf("[", colon) + 1, colon);
                                    string rowColSelectorValue = rowColSelector.Split('\"')[1];
                                    if (rowColSelector.Contains("\""))
                                    {
                                        rowColSelector = rowColSelector.Substring(0, rowColSelector.IndexOf("="));
                                        if (rowColSelector.Equals("name"))
                                        {
                                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.WhereColSelector, ActUIElement.eTableElementRunColSelectorValue.ColName.ToString());
                                        }
                                        else if (rowColSelector.Equals("title"))
                                        {
                                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.WhereColSelector, ActUIElement.eTableElementRunColSelectorValue.ColTitle.ToString());
                                        }
                                        else if (rowColSelector.Equals("number"))
                                        {
                                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.WhereColSelector, ActUIElement.eTableElementRunColSelectorValue.ColNum.ToString());
                                        }
                                    }
                                    else
                                    {
                                        newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.WhereColSelector, ActUIElement.eTableElementRunColSelectorValue.ColTitle.ToString());
                                    }
                                    newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.WhereColumnTitle, rowColSelectorValue);

                                    // Determine the Property Selector
                                    string   rowColProperty = cond.Substring(colon + 1);
                                    string[] properties     = rowColProperty.Split(new string[] { "\\[" }, StringSplitOptions.None);
                                    for (int i = 0; i < properties.Length; i++)
                                    {
                                        if (i > 1)
                                        {
                                        }
                                        string p  = new string(properties[i].Split('\"')[0].Where(c => char.IsLetter(c)).ToArray());
                                        string pv = properties[i].Split('\"')[1];
                                        if (pv.Equals("<empty>"))
                                        {
                                            pv = "";
                                        }
                                        string o = properties[i].Split('\"')[0].Substring(p.Length + 1);

                                        newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.WhereProperty, p);
                                        newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.WhereOperator,
                                                                          "=".Equals(o) ? ActUIElement.eTableElementRunColOperator.Equals.ToString() :
                                                                          "!=".Equals(o) ? ActUIElement.eTableElementRunColOperator.NotEquals.ToString() :
                                                                          "=~".Equals(o) ? ActUIElement.eTableElementRunColOperator.Contains.ToString() :
                                                                          "!~".Equals(o) ? ActUIElement.eTableElementRunColOperator.NotContains.ToString() :
                                                                          "=^".Equals(o) ? ActUIElement.eTableElementRunColOperator.StartsWith.ToString() :
                                                                          "!^".Equals(o) ? ActUIElement.eTableElementRunColOperator.NotStartsWith.ToString() :
                                                                          "=$".Equals(o) ? ActUIElement.eTableElementRunColOperator.EndsWith.ToString() :
                                                                          "!$".Equals(o) ? ActUIElement.eTableElementRunColOperator.NotEndsWith.ToString() : "");
                                        newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.WhereColumnValue, pv);
                                    }
                                }
                            }
                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.RowSelectorRadioParam, ActUIElement.eRadioButtonValueType.Where.ToString());
                        }
                    }
                    foreach (ActUIElement.eElementAction x in Enum.GetValues(typeof(ActUIElement.eElementAction)))
                    {
                        if (this.ControlAction.ToString().Equals(x.ToString()))
                        {
                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.ControlAction, x.ToString());
                            newAct.AddOrUpdateInputParamValue(ActUIElement.Fields.ControlActionValue, this.Value);
                        }
                    }
                    newAct.ElementLocateValue = locateValue.Split('/')[0].Substring(locateValue.Split('/')[0].LastIndexOf(":") + 1);
                }
            }
        }
        public UIElementTableConfigPage(ElementInfo ElementInfo, ObservableList <Act> Actions, ActUIElement Act = null)
        {
            eBaseWindow = BaseWindow.WindowExplorer;
            mAct        = new ActUIElement();
            string targetApp = App.BusinessFlow.CurrentActivity.TargetApplication;

            mPlatform = PlatformInfoBase.GetPlatformImpl((from x in App.UserProfile.Solution.ApplicationPlatforms where x.AppName == targetApp select x.Platform).FirstOrDefault());

            if (ElementInfo.ElementType.Contains("JEditor"))
            {
                mAct.ElementType   = eElementType.EditorPane;
                mAct.ElementAction = ActUIElement.eElementAction.JEditorPaneElementAction;
                mAct.AddOrUpdateInputParamValue(ActUIElement.Fields.SubElementType, ActUIElement.eSubElementType.HTMLTable.ToString());
                mAct.AddOrUpdateInputParamValue(ActUIElement.Fields.SubElementAction, ActUIElement.eElementAction.TableCellAction.ToString());
            }
            else
            {
                mAct.ElementType   = eElementType.Table;
                mAct.ElementAction = ActUIElement.eElementAction.TableCellAction;
            }

            mElementInfo = ElementInfo;
            mActions     = Actions;
            ShowCellActions();
            InitializeComponent();
            InitTableInfo();

            ShowTableControlActionConfigPage(mPlatform);
            SetComponents();
            SetDescriptionDetails();
        }
        private void UpdateRelatedActions()
        {
            string previousSelectedControlAction = null;

            if (mActions != null)
            {
                if (mActions.CurrentItem != null)
                {
                    if (mActions.CurrentItem is ActUIElement)
                    {
                        previousSelectedControlAction = ((ActUIElement)mActions.CurrentItem).GetOrCreateInputParam(ActUIElement.Fields.ControlAction).ToString();
                    }
                }

                mActions.Clear();
            }

            if (cmbColSelectorValue.ComboBox.SelectedIndex != -1)
            {
                mAct.AddOrUpdateInputParamValue(ActUIElement.Fields.ColSelectorValue, ((GingerCore.General.ComboEnumItem)cmbColSelectorValue.ComboBox.SelectedItem).Value.ToString());
            }

            string description = "";
            string rowVal      = "";
            string colVal      = "";

            if (RowNum.IsChecked == true)
            {
                mAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateRowType, "Row Number");
                if (RowSelectorValue != null)
                {
                    if (RowSelectorValue.ComboBox.SelectedIndex != -1)
                    {
                        rowVal = RowSelectorValue.ComboBox.SelectedItem.ToString();
                    }
                    else
                    {
                        rowVal = RowSelectorValue.ComboBox.Text;
                    }
                    description = " on Row:" + rowVal;
                }
            }
            else if (AnyRow.IsChecked == true)
            {
                mAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateRowType, "Any Row");
                description = " on Random Row";
            }
            else if (BySelectedRow.IsChecked == true)
            {
                mAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateRowType, "By Selected Row");
                description = " on Selected Row";
            }
            else if (Where.IsChecked == true)
            {
                mAct.AddOrUpdateInputParamValue(ActUIElement.Fields.LocateRowType, "Where");
                description = " on Row with condition";
            }

            if (cmbColumnValue != null)
            {
                if (cmbColumnValue.ComboBox.SelectedIndex != -1)
                {
                    colVal = cmbColumnValue.ComboBox.SelectedItem.ToString();
                }
                else
                {
                    colVal = cmbColumnValue.ComboBox.Text;
                }
                description = description + " and Column:" + colVal;
            }

            if (eBaseWindow.Equals(BaseWindow.WindowExplorer) && cmbColSelectorValue.ComboBox.SelectedIndex != -1 && WhereColumn != null && WhereColumn.ComboBox.SelectedIndex != -1 && RowSelectorValue != null &&
                WhereProperty != null && WhereProperty.ComboBox.SelectedIndex != -1 && WhereOperator != null && WhereOperator.ComboBox.SelectedIndex != -1)
            {
                List <string> descriptionString = new List <string>();
                descriptionString.Add("Get Value of Cell: ");
                descriptionString.Add("Set Value of Cell: ");
                descriptionString.Add("Type Value in Cell: ");
                descriptionString.Add("Click Cell: ");
                descriptionString.Add("WinClick Cell: ");
                descriptionString.Add("Get Selected Cell from Column: ");

                ActUIElement actObj = (ActUIElement)mAct.CreateCopy();
                actObj.AddOrUpdateInputParamValue(ActUIElement.Fields.ControlAction, ActUIElement.eElementAction.SetValue.ToString());
                actObj.Description = "Set Value of Cell: " + description;
                actObj.GetOrCreateInputParam(ActUIElement.Fields.WhereColSelector, mAct.GetInputParamValue(ActUIElement.Fields.WhereColSelector));
                actObj.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnTitle, mAct.GetInputParamValue(ActUIElement.Fields.WhereColumnTitle));
                actObj.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnValue, mAct.GetInputParamValue(ActUIElement.Fields.WhereColumnValue));
                actObj.GetOrCreateInputParam(ActUIElement.Fields.WhereOperator, mAct.GetInputParamValue(ActUIElement.Fields.WhereOperator));
                actObj.GetOrCreateInputParam(ActUIElement.Fields.WhereProperty, mAct.GetInputParamValue(ActUIElement.Fields.WhereProperty));
                mActions.Add(actObj);


                ActUIElement actObj1 = (ActUIElement)mAct.CreateCopy();;
                actObj1.AddOrUpdateInputParamValue(ActUIElement.Fields.ControlAction, ActUIElement.eElementAction.GetValue.ToString());
                actObj1.Description = "Get Value of Cell: " + description;
                actObj1.GetOrCreateInputParam(ActUIElement.Fields.WhereColSelector, mAct.GetInputParamValue(ActUIElement.Fields.WhereColSelector));
                actObj1.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnTitle, mAct.GetInputParamValue(ActUIElement.Fields.WhereColumnTitle));
                actObj1.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnValue, mAct.GetInputParamValue(ActUIElement.Fields.WhereColumnValue));
                actObj1.GetOrCreateInputParam(ActUIElement.Fields.WhereOperator, mAct.GetInputParamValue(ActUIElement.Fields.WhereOperator));
                actObj1.GetOrCreateInputParam(ActUIElement.Fields.WhereProperty, mAct.GetInputParamValue(ActUIElement.Fields.WhereProperty));
                mActions.Add(actObj1);


                ActUIElement actObj2 = (ActUIElement)mAct.CreateCopy();;
                actObj2.AddOrUpdateInputParamValue(ActUIElement.Fields.ControlAction, ActUIElement.eElementAction.Click.ToString());
                actObj2.Description = "Click Cell: " + description;
                actObj2.GetOrCreateInputParam(ActUIElement.Fields.WhereColSelector, mAct.GetInputParamValue(ActUIElement.Fields.WhereColSelector));
                actObj2.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnTitle, mAct.GetInputParamValue(ActUIElement.Fields.WhereColumnTitle));
                actObj2.GetOrCreateInputParam(ActUIElement.Fields.WhereColumnValue, mAct.GetInputParamValue(ActUIElement.Fields.WhereColumnValue));
                actObj2.GetOrCreateInputParam(ActUIElement.Fields.WhereOperator, mAct.GetInputParamValue(ActUIElement.Fields.WhereOperator));
                actObj2.GetOrCreateInputParam(ActUIElement.Fields.WhereProperty, mAct.GetInputParamValue(ActUIElement.Fields.WhereProperty));
                mActions.Add(actObj2);
            }
            if (previousSelectedControlAction != null)
            {
                if (mActions != null)
                {
                    foreach (ActUIElement act in mActions)
                    {
                        if (act.GetOrCreateInputParam(ActUIElement.Fields.ControlAction).ToString() == previousSelectedControlAction)
                        {
                            mActions.CurrentItem = act;
                            break;
                        }
                    }
                }
            }
            if (mActions != null && mActions.CurrentItem == null && mActions.Count > 0)
            {
                mActions.CurrentItem = mActions[0];
            }
        }
        string IObsoleteAction.TargetActionTypeName()
        {
            ActUIElement newUIElementAction = new ActUIElement();

            return(newUIElementAction.ActionDescription);
        }
Example #14
0
        private void HandleUIElementAction(Act actPBC)
        {
            ActUIElement actUIPBC = (ActUIElement)actPBC;

            object AE = null;

            if (!actUIPBC.ElementType.Equals(eElementType.Window) && !actUIPBC.ElementAction.Equals(ActUIElement.eElementAction.Switch))
            {
                string locateValue = actUIPBC.ElementLocateValueForDriver;
                AE = mUIAutomationHelper.FindElementByLocator((eLocateBy)actUIPBC.ElementLocateBy, locateValue);

                if (AE == null && actUIPBC.ElementAction != ActUIElement.eElementAction.IsEnabled)
                {
                    actUIPBC.Error = "Element not Found - " + actUIPBC.ElementLocateBy + " " + actUIPBC.ElementLocateValueForDriver;
                    return;
                }
            }


            switch (actUIPBC.ElementAction)
            {
            case ActUIElement.eElementAction.DragDrop:
                mUIAutomationHelper.DragAndDrop(AE, actUIPBC);
                break;

            case ActUIElement.eElementAction.ClickAndValidate:
                string status = mUIAutomationHelper.ClickAndValidteHandler(AE, actUIPBC);
                if (!status.Contains("Clicked Successfully"))
                {
                    actUIPBC.Error += status;
                }
                else
                {
                    actUIPBC.ExInfo += status;
                    actUIPBC.AddOrUpdateReturnParamActual("Actual", status);
                }
                break;

            case ActUIElement.eElementAction.SendKeysAndValidate:
                string status1 = mUIAutomationHelper.SendKeysAndValidateHandler(AE, actUIPBC);
                if (!status1.Contains("true"))
                {
                    actUIPBC.Error += status1;
                }
                else
                {
                    actUIPBC.ExInfo += status1;
                    actUIPBC.AddOrUpdateReturnParamActual("Actual", status1);
                }
                break;

            case ActUIElement.eElementAction.SelectandValidate:
                string statusSel = mUIAutomationHelper.SelectAndValidateHandler(AE, actUIPBC);
                if (!statusSel.Contains("true"))
                {
                    actUIPBC.Error += statusSel;
                }
                else
                {
                    actUIPBC.ExInfo += statusSel;
                    actUIPBC.AddOrUpdateReturnParamActual("Actual", statusSel);
                }
                break;

            case ActUIElement.eElementAction.Switch:
                mUIAutomationHelper.ActUISwitchWindow(actUIPBC);
                break;

            default:
                actUIPBC.Error = string.Format("Selected '{0}' Operation not supported for 'PBDriver'", actUIPBC.ElementAction.ToString());
                break;
            }
        }
Example #15
0
        Act IObsoleteAction.GetNewAction()
        {
            bool uIElementTypeAssigned = false;

            AutoMapper.MapperConfiguration mapConfigUIElement = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap <Act, ActUIElement>(); });
            ActUIElement NewActUIElement = mapConfigUIElement.CreateMapper().Map <Act, ActUIElement>(this);

            AutoMapper.MapperConfiguration mapConfigBrowserElementt = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap <Act, ActBrowserElement>(); });
            ActBrowserElement NewActBrowserElement = mapConfigBrowserElementt.CreateMapper().Map <Act, ActBrowserElement>(this);

            Type currentType = GetActionTypeByElementActionName(GenElementAction);

            if (currentType == typeof(ActBrowserElement))
            {
                switch (GenElementAction)
                {
                case eGenElementAction.Back:
                    NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.NavigateBack;
                    break;

                case eGenElementAction.CloseBrowser:
                    NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.Close;
                    break;

                default:
                    NewActBrowserElement.ControlAction = (ActBrowserElement.eControlAction)System.Enum.Parse(typeof(ActBrowserElement.eControlAction), GenElementAction.ToString());
                    break;
                }
            }
            else if (currentType == typeof(ActUIElement))
            {
                switch (GenElementAction)
                {
                case eGenElementAction.Click:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.JavaScriptClick;
                    break;

                case eGenElementAction.RightClick:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.MouseRightClick;
                    break;

                case eGenElementAction.Visible:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.IsVisible;
                    break;

                case eGenElementAction.SelectFromListScr:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SelectByIndex;
                    NewActUIElement.ElementType   = eElementType.List;
                    uIElementTypeAssigned         = true;
                    break;

                case eGenElementAction.KeyboardInput:
                case eGenElementAction.KeyType:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SendKeys;
                    break;

                case eGenElementAction.SelectFromDropDown:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SelectByText;
                    NewActUIElement.ElementType   = eElementType.ComboBox;
                    uIElementTypeAssigned         = true;
                    break;

                case eGenElementAction.GetInnerText:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.GetText;
                    break;

                case eGenElementAction.GetCustomAttribute:
                case eGenElementAction.GetElementAttributeValue:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.GetAttrValue;
                    break;

                case eGenElementAction.BatchClicks:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.MultiClicks;
                    break;

                case eGenElementAction.BatchSetValues:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.MultiSetValue;
                    break;

                case eGenElementAction.SimpleClick:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.Click;
                    break;

                case eGenElementAction.Disabled:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.IsDisabled;
                    break;

                case eGenElementAction.Enabled:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.IsEnabled;
                    break;

                case eGenElementAction.GetNumberOfElements:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.GetItemCount;
                    break;

                case eGenElementAction.XYClick:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.ClickXY;
                    break;

                case eGenElementAction.Focus:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.SetFocus;
                    break;

                case eGenElementAction.RunJavaScript:
                    NewActUIElement.ElementAction = ActUIElement.eElementAction.RunJavaScript;
                    break;

                default:
                    NewActUIElement.ElementAction = (ActUIElement.eElementAction)System.Enum.Parse(typeof(ActUIElement.eElementAction), GenElementAction.ToString());
                    break;
                }
            }

            if (currentType == typeof(ActUIElement))
            {
                NewActUIElement.ElementLocateBy = (eLocateBy)((int)this.LocateBy);
                if (!string.IsNullOrEmpty(this.LocateValue))
                {
                    NewActUIElement.ElementLocateValue = String.Copy(this.LocateValue);
                }


                if (!uIElementTypeAssigned)
                {
                    NewActUIElement.ElementType = eElementType.Unknown;
                }
                if (!NewActUIElement.Platforms.Contains(this.Platform))
                {
                    NewActUIElement.Platform = ePlatformType.Web; // ??? to check
                }

                return(NewActUIElement);
            }

            if (currentType == typeof(ActBrowserElement))
            {
                return(NewActBrowserElement);
            }
            return(null);
        }
Example #16
0
        private void HandleUIElementAction(Act actPBC)
        {
            ActUIElement actUIPBC    = (ActUIElement)actPBC;
            string       locateValue = actUIPBC.ElementLocateValueForDriver;
            object       AE          = mUIAutomationHelper.FindElementByLocator((eLocateBy)actUIPBC.ElementLocateBy, locateValue);

            if (AE == null && actUIPBC.ElementAction != ActUIElement.eElementAction.IsEnabled)
            {
                actUIPBC.Error = "Element not Found - " + actUIPBC.ElementLocateBy + " " + actUIPBC.ElementLocateValueForDriver;
                return;
            }

            switch (actUIPBC.ElementAction)
            {
            case ActUIElement.eElementAction.DragDrop:
                mUIAutomationHelper.DragAndDrop(AE, actUIPBC);
                break;

            case ActUIElement.eElementAction.ClickAndValidate:
                string status = mUIAutomationHelper.ClickAndValidteHandler(AE, actUIPBC);
                if (!status.Contains("Clicked Successfully"))
                {
                    actUIPBC.Error += status;
                }
                else
                {
                    actUIPBC.ExInfo += status;
                    actUIPBC.AddOrUpdateReturnParamActual("Actual", status);
                }
                break;

            case ActUIElement.eElementAction.SendKeysAndValidate:
                string status1 = mUIAutomationHelper.SendKeysAndValidateHandler(AE, actUIPBC);
                if (!status1.Contains("true"))
                {
                    actUIPBC.Error += status1;
                }
                else
                {
                    actUIPBC.ExInfo += status1;
                    actUIPBC.AddOrUpdateReturnParamActual("Actual", status1);
                }
                break;

            case ActUIElement.eElementAction.SelectandValidate:
                string statusSel = mUIAutomationHelper.SelectAndValidateHandler(AE, actUIPBC);
                if (!statusSel.Contains("true"))
                {
                    actUIPBC.Error += statusSel;
                }
                else
                {
                    actUIPBC.ExInfo += statusSel;
                    actUIPBC.AddOrUpdateReturnParamActual("Actual", statusSel);
                }
                break;

            default:
                actUIPBC.Error = "Unable to perform operation";
                break;
            }
        }
Example #17
0
 public override void DragAndDrop(object element, ActUIElement action)
 {
     throw new NotImplementedException();
 }
        String IObsoleteAction.TargetActionTypeName()
        {
            ActUIElement actUIElement = new ActUIElement();

            return(actUIElement.ActionDescription);
        }
Example #19
0
 public override string SendKeysAndValidateHandler(object element, ActUIElement action)
 {
     throw new NotImplementedException();
 }
        private Act SetActionDetails(Act act)
        {
            act.Active             = true;
            act.AddNewReturnParams = true;
            act.Value = xValueTextBox.Text;
            //Set action unique input values
            if (mActInputValues != null)
            {
                foreach (ActInputValue iv in mActInputValues)
                {
                    if (iv.Value != null)
                    {
                        act.AddOrUpdateInputParamValue(iv.Param, iv.Value);
                    }
                }
            }

            ElementLocator EL = (ElementLocator)mLocators.CurrentItem;

            if (EL == null)
            {
                EL = (ElementLocator)mElementInfo.Locators.CurrentItem;
            }

            if (DefaultAction.GetType() == typeof(ActUIElement))
            {
                //Set UIElement action locator
                ActUIElement actUI = (ActUIElement)act;

                if (EL != null && actUI.ElementLocateBy != eLocateBy.POMElement)
                {
                    actUI.ElementLocateBy    = EL.LocateBy;
                    actUI.ElementLocateValue = EL.LocateValue;
                    actUI.ElementType        = mElementInfo.ElementTypeEnum;
                }

                //TODO: Remove below  if once one of the field from Value and Value to select is removed
                if (actUI.ElementAction == ActUIElement.eElementAction.Click ||
                    actUI.ElementAction == ActUIElement.eElementAction.Select ||
                    actUI.ElementAction == ActUIElement.eElementAction.GetControlProperty ||
                    actUI.ElementAction == ActUIElement.eElementAction.AsyncSelect ||
                    actUI.ElementAction == ActUIElement.eElementAction.SelectByIndex)
                {
                    actUI.AddOrUpdateInputParamValue(ActUIElement.Fields.ValueToSelect, act.Value);
                }
                else if (actUI.ElementAction.Equals(ActUIElement.eElementAction.TableCellAction))
                {
                    actUI.AddOrUpdateInputParamValue(ActUIElement.Fields.ControlActionValue, act.Value);
                }

                actUI.AddOrUpdateInputParamValue(ActUIElement.Fields.ElementType, actUI.ElementType.ToString());

                act = actUI;
            }
            else if (DefaultAction.GetType() == typeof(ActBrowserElement))
            {
                //Set UIElement action locator
                ActBrowserElement actBrowser = (ActBrowserElement)act;

                if (EL != null && actBrowser.LocateBy != eLocateBy.POMElement)
                {
                    actBrowser.LocateBy    = EL.LocateBy;
                    actBrowser.LocateValue = EL.LocateValue;
                }
            }
            else
            {
                //Set action locator
                act.LocateBy    = EL.LocateBy;
                act.LocateValue = EL.LocateValue;
            }
            return(act);
        }
Example #21
0
        public void ActivityVariableDependancyTest_WithCreateInstance()
        {
            //Arrange
            BusinessFlow bf = new BusinessFlow("Test");

            Activity activity = new Activity();
            VariableSelectionList selectionList2 = new VariableSelectionList();

            selectionList2.Name = "activityVariable1";
            selectionList2.OptionalValuesList.Add(new OptionalValue("c"));
            selectionList2.OptionalValuesList.Add(new OptionalValue("d"));

            VariableDependency vd = new VariableDependency(selectionList2.Guid, selectionList2.ItemName, selectionList2.Value);

            ActUIElement actGotoURL = new ActUIElement();

            actGotoURL.Description = "www.google.com";
            actGotoURL.VariablesDependencies.Add(vd);
            ActDummy actDummy = new ActDummy();

            actDummy.Description = "www.google.com";
            actDummy.VariablesDependencies.Add(vd);
            activity.Variables.Add(selectionList2);
            activity.Acts.Add(actGotoURL);
            activity.Acts.Add(actDummy);
            Activity activity2 = new Activity();
            ActDummy act2      = new ActDummy();

            act2.Description = "www.google.com";
            activity2.Acts.Add(act2);
            VariableSelectionList selectionList = new VariableSelectionList();

            selectionList.Name = "bfVariable1";
            selectionList.OptionalValuesList.Add(new OptionalValue("a"));
            selectionList.OptionalValuesList.Add(new OptionalValue("b"));

            bf.Variables.Add(selectionList);


            VariableDependency vd1 = new VariableDependency(selectionList.Guid, selectionList.ItemName, selectionList.Value);

            activity.VariablesDependencies.Add(vd1);
            activity2.VariablesDependencies.Add(vd1);

            bf.Activities.RemoveAt(0);
            bf.Activities.Add(activity);
            bf.Activities.Add(activity2);


            //Act
            BusinessFlow bfCopy = (BusinessFlow)bf.CreateInstance();

            Guid newBFVarGuid       = bfCopy.Variables.Where(x => x.Name == "bfVariable1").FirstOrDefault().Guid;
            Guid newActivityVarGuid = bfCopy.Activities[0].Variables[0].Guid;

            //Assert
            Assert.AreEqual(newBFVarGuid, bfCopy.Activities[0].VariablesDependencies[0].VariableGuid);
            Assert.AreEqual(newBFVarGuid, bfCopy.Activities[1].VariablesDependencies[0].VariableGuid);
            Assert.AreEqual(newActivityVarGuid, bfCopy.Activities[0].Acts[0].VariablesDependencies[0].VariableGuid);
            Assert.AreEqual(newActivityVarGuid, bfCopy.Activities[0].Acts[1].VariablesDependencies[0].VariableGuid);
        }
 public abstract void DragAndDrop(object element, ActUIElement action);
Example #23
0
        public void BackUpRestore()
        {
            //Arrange
            int    ActivitiesToCreate = 5;
            string BizFlowName        = "Biz flow Back/Rest";
            string BizFlowDescription = "Desc Back/Rest tester";

            BusinessFlow BF = new BusinessFlow()
            {
                Name = BizFlowName
            };

            BF.Status     = BusinessFlow.eBusinessFlowStatus.Development;
            BF.Activities = new ObservableList <Activity>();
            ObservableList <Activity> OriginalActivitiesObj = BF.Activities;

            for (int i = 1; i <= ActivitiesToCreate; i++)
            {
                Activity a = new Activity()
                {
                    ActivityName = "Activity " + i, Description = "desc" + i, Status = eRunStatus.Passed
                };
                BF.AddActivity(a);
            }

            // Create Activity to check ref
            Activity a6 = new Activity()
            {
                ActivityName = "a6"
            };

            BF.Activities.Add(a6);

            // Add one action to make sure backup drill down, and restore the ref item not a copy
            ActUIElement act1 = new ActUIElement();

            act1.Description = "Goto URL 1";
            a6.Acts.Add(act1);

            //add action with input/output vals
            act1.InputValues = new ObservableList <ActInputValue>();
            string        firstInputValName = "Param1";
            ActInputValue firstInputVal     = new ActInputValue()
            {
                Param = firstInputValName
            };

            act1.InputValues.Add(firstInputVal);
            act1.InputValues.Add(new ActInputValue()
            {
                Param = "Param2"
            });

            //add flow control
            act1.FlowControls = new ObservableList <FlowControl>();
            act1.FlowControls.Add(new GingerCore.FlowControlLib.FlowControl()
            {
                Condition = "A=B", FlowControlAction = eFlowControlAction.GoToActivity
            });
            eFlowControlAction secondFlowControlAction = eFlowControlAction.RerunAction;

            GingerCore.FlowControlLib.FlowControl secondFlowControl = new GingerCore.FlowControlLib.FlowControl()
            {
                Condition = "C>123", FlowControlAction = secondFlowControlAction
            };
            act1.FlowControls.Add(secondFlowControl);
            act1.FlowControls.Add(new GingerCore.FlowControlLib.FlowControl()
            {
                Condition = "D=111", FlowControlAction = eFlowControlAction.StopRun
            });

            //BF Variables
            VariableString v = new VariableString();

            v.Name        = "Var1";
            v.Description = "VDesc 1";
            BF.AddVariable(v);
            VariableSelectionList sl = new VariableSelectionList();

            sl.Name = "Var 2";
            sl.OptionalValuesList = new ObservableList <OptionalValue>();
            sl.OptionalValuesList.Add(new OptionalValue("11"));
            sl.OptionalValuesList.Add(new OptionalValue("22"));
            sl.OptionalValuesList.Add(new OptionalValue("33"));
            BF.AddVariable(sl);

            // BF.SaveBackup();

            BF.SaveBackup();

            //Erase/Modify some stuff
            BF.Name        = "zzzz";
            BF.Description = BizFlowDescription;
            BF.Status      = BusinessFlow.eBusinessFlowStatus.Retired;
            BF.Activities[1].Description = "AAAA";
            BF.Activities.Remove(BF.Activities[2]);
            BF.Activities.Remove(BF.Activities[3]);
            act1.Description = "ZZZZZ";

            act1.InputValues[0].Param = "qqq";
            act1.InputValues.Remove(act1.InputValues[1]);

            act1.FlowControls[1].FlowControlAction = eFlowControlAction.MessageBox;
            act1.FlowControls.Add(new GingerCore.FlowControlLib.FlowControl()
            {
                Condition = "Val=123"
            });
            act1.FlowControls.Add(new GingerCore.FlowControlLib.FlowControl()
            {
                Condition = "Val=555"
            });

            sl.OptionalValuesList[0].Value = "aaaa";
            sl.OptionalValuesList.Add(new OptionalValue("44"));
            sl.OptionalValuesList.Add(new OptionalValue("55"));

            // BF.RestoreFromBackup();
            BF.RestoreFromBackup();

            // Assert
            Assert.AreEqual(BF.Name, BizFlowName, "BF.Name");
            Assert.AreEqual(BF.Description, null, "BF.Description");

            // check enum restore
            Assert.AreEqual(BF.Status, BusinessFlow.eBusinessFlowStatus.Development, "BF.Status");
            Assert.AreEqual(BF.Activities.Count(), ActivitiesToCreate + 1, "BF.Activities.Count()");

            //check original list ref obj
            Assert.AreEqual(BF.Activities, OriginalActivitiesObj, "BF.Activities REF");
            Assert.AreEqual(BF.Activities[0].Description, "desc1", "BF.Activities[0].Description");
            Assert.AreEqual(BF.Activities[5].ActivityName, "a6", "BF.Activities[5].ActivityName");

            // Check original action ref is back
            Assert.AreEqual(BF.Activities[5], a6, "BF.Activities[5] REF");
            Assert.AreEqual(act1.Description, "Goto URL 1", "act1.Description");
            Assert.AreEqual(a6.Acts[0], act1, "a6.Acts[0]");

            //check Action input values
            Assert.AreEqual(act1.InputValues.Count, 2, "act1.InputValues.Count");
            Assert.AreEqual(act1.InputValues[0], firstInputVal, "act1.InputValues[0] REF");
            Assert.AreEqual(act1.InputValues[0].Param, firstInputValName, "act1.InputValues[0].Param");

            //check Action flow control
            Assert.AreEqual(act1.FlowControls.Count, 3, "act1.FlowControls.Count");
            Assert.AreEqual(act1.FlowControls[1], secondFlowControl, "act1.FlowControls[1] REF");
            Assert.AreEqual(act1.FlowControls[1].FlowControlAction, secondFlowControlAction, "act1.FlowControls[1].FlowControlAction");

            //BF variables
            Assert.AreEqual(BF.Variables.Count, 2, "BF.Variables.Count");
            Assert.AreEqual(BF.Variables[1], sl, "BF.Variables[0] REF");
            Assert.AreEqual(((VariableSelectionList)BF.Variables[1]).OptionalValuesList[0].Value, "11", "BF.Variables[0].Value");
        }
 public abstract string SelectAndValidateHandler(object element, ActUIElement action);
Example #25
0
        public override Act GetPlatformActionByElementInfo(ElementInfo elementInfo, ElementActionCongifuration actConfig)
        {
            Act elementAction = null;

            if (elementInfo != null)
            {
                ElementTypeData elementTypeOperations = GetPlatformElementTypesData().Where(x => x.ElementType == elementInfo.ElementTypeEnum).FirstOrDefault();
                if (actConfig != null)
                {
                    if (string.IsNullOrWhiteSpace(actConfig.Operation))
                    {
                        actConfig.Operation = SetElementOperation(elementInfo.ElementTypeEnum, actConfig);
                    }
                }
                if ((elementTypeOperations != null) && ((elementTypeOperations.ElementOperationsList != null)) && (elementTypeOperations.ElementOperationsList.Count > 0))
                {
                    if (elementTypeOperations.ActionType == typeof(ActBrowserElement))
                    {
                        elementAction = new ActBrowserElement()
                        {
                            Description   = string.IsNullOrWhiteSpace(actConfig.Description) ? "Browser Action : " + actConfig.Operation + " - " + elementInfo.ItemName : actConfig.Description,
                            ControlAction = (ActBrowserElement.eControlAction)System.Enum.Parse(typeof(ActBrowserElement.eControlAction), actConfig.Operation),
                            LocateBy      = (eLocateBy)System.Enum.Parse(typeof(eLocateBy), Convert.ToString(actConfig.LocateBy)),
                            Value         = actConfig.ElementValue,
                            LocateValue   = actConfig.LocateValue
                        };
                    }
                    else if (elementTypeOperations.ActionType == typeof(ActUIElement))
                    {
                        elementAction = new ActUIElement()
                        {
                            Description        = string.IsNullOrWhiteSpace(actConfig.Description) ? "UI Element Action : " + actConfig.Operation + " - " + elementInfo.ItemName : actConfig.Description,
                            ElementAction      = (ActUIElement.eElementAction)System.Enum.Parse(typeof(ActUIElement.eElementAction), actConfig.Operation),
                            ElementLocateValue = actConfig.LocateValue,
                            Value = actConfig.ElementValue
                        };

                        if (actConfig.AddPOMToAction)
                        {
                            elementAction.Description = actConfig.Operation + " - " + elementInfo.ElementName;
                            PropertyInfo pLocateBy = elementAction.GetType().GetProperty(nameof(ActUIElement.ElementLocateBy));
                            if (pLocateBy != null)
                            {
                                if (pLocateBy.PropertyType.IsEnum)
                                {
                                    pLocateBy.SetValue(elementAction, Enum.Parse(pLocateBy.PropertyType, nameof(eLocateBy.POMElement)));
                                }
                            }

                            PropertyInfo pLocateVal = elementAction.GetType().GetProperty(nameof(ActUIElement.ElementLocateValue));
                            if (pLocateVal != null)
                            {
                                pLocateVal.SetValue(elementAction, string.Format("{0}_{1}", actConfig.POMGuid, actConfig.ElementGuid));
                            }

                            PropertyInfo pElementType = elementAction.GetType().GetProperty(nameof(ActUIElement.ElementType));
                            if (pElementType != null && pElementType.PropertyType.IsEnum)
                            {
                                pElementType.SetValue(elementAction, ((ElementInfo)actConfig.LearnedElementInfo).ElementTypeEnum);
                            }
                        }
                    }
                }
            }
            else
            {
                elementAction = new ActUIElement()
                {
                    Description        = string.IsNullOrWhiteSpace(actConfig.Description) ? "UI Element Action : " + actConfig.Operation + " - " + elementInfo.ItemName : actConfig.Description,
                    ElementLocateBy    = (eLocateBy)System.Enum.Parse(typeof(eLocateBy), Convert.ToString(actConfig.LocateBy)),
                    ElementAction      = (ActUIElement.eElementAction)System.Enum.Parse(typeof(ActUIElement.eElementAction), actConfig.Operation),
                    ElementLocateValue = actConfig.LocateValue,
                    ElementType        = (eElementType)System.Enum.Parse(typeof(eElementType), Convert.ToString(actConfig.Type)),
                    Value = actConfig.ElementValue
                };
            }
            return(elementAction);
        }