private Act GetNewActionForJava() { if (GenElementAction.Equals(eGenElementAction.SwitchFrame) || GenElementAction.Equals(eGenElementAction.RunJavaScript)) { ActBrowserElement NewActBrowserElement = GetNewBrowserElementFromAutoMapper(); if (GenElementAction.Equals(eGenElementAction.SwitchFrame)) { NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.SwitchFrame; } else if (GenElementAction.Equals(eGenElementAction.RunJavaScript)) { NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.RunJavaScript; } return(NewActBrowserElement); } else { ActUIElement newActUIElement = GetNewUIElementFromAutoMapper(); newActUIElement.GetOrCreateInputParam(ActUIElement.Fields.IsWidgetsElement, "true"); newActUIElement.ElementLocateBy = this.LocateBy; newActUIElement.ElementLocateValue = this.LocateValue; newActUIElement.ElementAction = MapJavaGenericElementAction(GenElementAction); newActUIElement.GetOrCreateInputParam(ActUIElement.Fields.ValueToSelect, this.Value); if (this.ReturnValues.Count > 0) { if (this.ReturnValues[0].Param == "Actual") { newActUIElement.ReturnValues[0].Param = "Actual0"; } } return(newActUIElement); } }
Act IObsoleteAction.GetNewAction() { 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 eHandleBrowseAlert.AcceptAlertBox: NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.AcceptMessageBox; break; case eHandleBrowseAlert.DismissAlertBox: NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.DismissMessageBox; break; case eHandleBrowseAlert.GetAlertBoxText: NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.GetMessageBoxText; break; case eHandleBrowseAlert.SendKeysAlertBox: NewActBrowserElement.ControlAction = ActBrowserElement.eControlAction.SetAlertBoxText; break; default: NewActBrowserElement.ControlAction = (ActBrowserElement.eControlAction)System.Enum.Parse(typeof(ActBrowserElement.eControlAction), GenElementAction.ToString()); break; } } if (currentType == typeof(ActBrowserElement)) { return(NewActBrowserElement); } return(null); }
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.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; 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 } NewActUIElement.AddOrUpdateInputParamValue(ActUIElement.Fields.ValueToSelect, this.GetInputParamValue("Value")); return(NewActUIElement); } if (currentType == typeof(ActBrowserElement)) { return(NewActBrowserElement); } return(null); }
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); }
private ActUIElement.eElementAction MapJavaGenericElementAction(eGenElementAction genElementAction) { ActUIElement.eElementAction elementAction; switch (genElementAction) { case eGenElementAction.SetValue: case eGenElementAction.GetValue: case eGenElementAction.Click: case eGenElementAction.AsyncClick: case eGenElementAction.RunJavaScript: case eGenElementAction.ScrollDown: case eGenElementAction.ScrollUp: elementAction = (ActUIElement.eElementAction)Enum.Parse(typeof(ActUIElement.eElementAction), GenElementAction.ToString()); break; case eGenElementAction.Enabled: elementAction = ActUIElement.eElementAction.IsEnabled; break; case eGenElementAction.Visible: elementAction = ActUIElement.eElementAction.IsVisible; break; case eGenElementAction.SelectFromDropDownByIndex: elementAction = ActUIElement.eElementAction.SelectByIndex; break; case eGenElementAction.SelectFromDropDown: elementAction = ActUIElement.eElementAction.Select; break; case eGenElementAction.FireMouseEvent: case eGenElementAction.FireSpecialEvent: elementAction = ActUIElement.eElementAction.TriggerJavaScriptEvent; break; default: throw new NotSupportedException(); } return(elementAction); }