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