public override void RunAction(Act act) { //TODO: add func to Act + Enum for switch string actClass = act.GetType().ToString(); mUIAutomationHelper.mLoadTimeOut = mActionTimeout; mUIAutomationHelper.taskFinished = false; //TODO: avoid hard coded string... actClass = actClass.Replace("GingerCore.Actions.", ""); if (actClass != "ActUIASwitchWindow" && actClass != "ActSwitchWindow") { CheckRetrySwitchWindowIsNeeded(); } if (act.Timeout != null) { mUIAutomationHelper.mLoadTimeOut = act.Timeout; } try { Reporter.ToLog(eLogLevel.DEBUG, "Start Executing action of type '" + actClass + "' Description is" + act.Description); switch (actClass) { case "ActPBControl": ActPBControl actPBC = (ActPBControl)act; HandlePBControlAction(actPBC); break; case "ActGenElement": ActGenElement AGE = (ActGenElement)act; HandlePBGenericWidgetControlAction(AGE); break; case "ActBrowserElement": ActBrowserElement actBE = (ActBrowserElement)act; HandlePBBrowserElementAction(actBE); break; //TODO: ActSwitchWindow is the correct approach for switch window. And we should guide the users accordingly. //Down the line we need to clean up ActUIASwitchWindow. This is old way, but we keep it to support old actions case "ActUIASwitchWindow": mUIAutomationHelper.SwitchWindow((ActUIASwitchWindow)act); break; case "ActSwitchWindow": mUIAutomationHelper.SmartSwitchWindow((ActSwitchWindow)act); break; case "ActMenuItem": ActMenuItem actMenuItem = (ActMenuItem)act; HandleMenuControlAction(actMenuItem); break; case "ActWindow": ActWindow actWindow = (ActWindow)act; HandleWindowControlAction(actWindow); break; //case "ActUIAButton": // ActUIAButton b = (ActUIAButton)act; // UIA.ClickButton(b); // break; //case "ActUIATextBox": // ActUIATextBox ATB = (ActUIATextBox)act; // if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.SetValue) // { // UIA.SetTextBoxValue(ATB); // return; // } // if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.GetValue) UIA.GetTextBoxValue(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.GetValue) UIA.GetTextBoxValue(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.IsDisabled) UIA.IsTextBoxDisabled(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.GetFont) UIA.GetTextBoxFont(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.IsPrepopulated) UIA.IsTextBoxPrepopulated(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.IsRequired) UIA.IsTextBoxRequired(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.IsDisplayed) UIA.IsTextBoxDisplayed(ATB); // //if (ATB.UIATextBoxAction == ActUIATextBox.eUIATextBoxAction.GetInputLength) UIA.GetTextBoxInputLength(ATB); // break; //case "ActUIALabel": // if (((ActUIALabel)act).LabelAction == ActUIALabel.eLabelAction.GetForeColor) UIA.LabelGetColor((ActUIALabel)act); // break; //TODO: What Jave is doing here? is it needed? case "Java.ActTableElement": ActTableElement actTable = (ActTableElement)act; mUIAutomationHelper.HandleGridControlAction(actTable); break; case "ActTableElement": ActTableElement actTable1 = (ActTableElement)act; mUIAutomationHelper.HandleGridControlAction(actTable1); break; case "ActSmartSync": mUIAutomationHelper.SmartSyncHandler((ActSmartSync)act); break; //case "ActUIAClickOnPoint": // ActUIAClickOnPoint ACP = (ActUIAClickOnPoint)act; // if (ACP.ActUIAClickOnPointAction == ActUIAClickOnPoint.eUIAClickOnPointAction.ClickXY) UIA.ClickOnPoint(ACP); // break; case "ActScreenShot": try { //TODO: Implement Multi window capture if (act.WindowsToCapture == Act.eWindowsToCapture.AllAvailableWindows) { List <AppWindow> list = mUIAutomationHelper.GetListOfDriverAppWindows(); List <Bitmap> bList; foreach (AppWindow aw in list) { Bitmap bmp = mUIAutomationHelper.GetAppWindowAsBitmap(aw); act.AddScreenShot(bmp); bList = mUIAutomationHelper.GetAppDialogAsBitmap(aw); foreach (Bitmap tempbmp in bList) { act.AddScreenShot(tempbmp); } bList.Clear(); } } else { Bitmap bmp = mUIAutomationHelper.GetCurrentWindowBitmap(); act.AddScreenShot(bmp); } return; } catch (Exception ex) { act.Error = "Error: Action failed to be performed, Details: " + ex.Message; } break; //case "ActUIAImage": // if (((ActUIAImage)act).ImageAction == ActUIAImage.eImageAction.IsVisible) UIA.ImageIsVisible((ActUIAImage)act); // break; //case "ActPBControl": // ActPBControl APBC = (ActPBControl)act; // RunControlAction(APBC); // break; //case "ActMenuItem": // ActMenuItem ami = (ActMenuItem)act; // MenuItem(ami); // break; case "Common.ActUIElement": //ActUIElement actUIPBC = (ActUIElement)act; HandleUIElementAction(act); break; default: throw new Exception("Action unknown/Not Impl in Driver - " + this.GetType().ToString()); } } catch (System.Runtime.InteropServices.COMException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (ElementNotAvailableException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (ArgumentException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (Exception e) { Reporter.ToLog(eLogLevel.WARN, "Exception at Run action", e); act.Error = e.Message; } }
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); }
private void HandlePBBrowserElementAction(ActBrowserElement actBE) { string result = ""; switch (actBE.ControlAction) { case ActBrowserElement.eControlAction.InitializeBrowser: object AE = mUIAutomationHelper.GetActElement(actBE); if (AE == null) { actBE.Error = "Element not Found - " + actBE.LocateBy + " " + actBE.LocateValueCalculated; return; } result = mUIAutomationHelper.InitializeBrowser(AE); if (result.Equals("true")) { actBE.AddOrUpdateReturnParamActual("Actual", result); actBE.ExInfo = "Browser Initialized"; } else { actBE.Error = "Unable to initialize browser"; } break; case ActBrowserElement.eControlAction.GetPageSource: result = mUIAutomationHelper.GetHTMLHelper().GetPageInfo("PageSource"); if (!result.Equals("")) { actBE.AddOrUpdateReturnParamActual("Actual", result); actBE.ExInfo = result; } else { actBE.Error = "Unable to fetch Page Source"; } break; case ActBrowserElement.eControlAction.GetPageURL: result = mUIAutomationHelper.GetHTMLHelper().GetPageInfo("PageURL"); if (!result.Equals("")) { actBE.AddOrUpdateReturnParamActual("Actual", result); actBE.ExInfo = result; } else { actBE.Error = "Unable to get Page URL"; } break; case ActBrowserElement.eControlAction.SwitchFrame: result = mUIAutomationHelper.GetHTMLHelper().SwitchFrame(actBE.LocateBy, actBE.LocateValueCalculated); if (result.Equals("true")) { actBE.AddOrUpdateReturnParamActual("Actual", result); actBE.ExInfo = "Switched to frame"; } else { actBE.Error = "Unable Switch frame"; } break; case ActBrowserElement.eControlAction.SwitchToDefaultFrame: mUIAutomationHelper.GetHTMLHelper().SwitchToDefaultFrame(); actBE.AddOrUpdateReturnParamActual("Actual", result); actBE.ExInfo = "Switched to Default Frame"; break; default: actBE.Error = "Unable to perform operation"; break; } }
public override void RunAction(Act act) { //TODO: add func to Act + Enum for switch string actClass = act.GetType().ToString(); mUIAutomationHelper.mLoadTimeOut = mActionTimeout; mUIAutomationHelper.taskFinished = false; //TODO: avoid hard coded string... actClass = actClass.Replace("GingerCore.Actions.", ""); actClass = actClass.Replace("Windows.", ""); if (actClass != "ActSwitchWindow" || (actClass == "ActWindow" && ((ActWindow)act).WindowActionType != ActWindow.eWindowActionType.Switch)) { CheckRetrySwitchWindowIsNeeded(); } if (act.Timeout != null) { mUIAutomationHelper.mLoadTimeOut = act.Timeout; } try { switch (actClass) { case "ActWindow": ActWindow actWindow = (ActWindow)act; HandleWindowAction(actWindow); break; //TODO: ActSwitchWindow is the correct approach for switch window. And we should guide the users accordingly. case "ActSwitchWindow": mUIAutomationHelper.SmartSwitchWindow((ActSwitchWindow)act); break; case "ActWindowsControl": HandleWindowsControlAction((ActWindowsControl)act); break; case "ActGenElement": ActGenElement AGE = (ActGenElement)act; HandleWindowsGenericWidgetControlAction(AGE); break; case "ActMenuItem": ActMenuItem actMenuItem = (ActMenuItem)act; HandleMenuControlAction(actMenuItem); break; case "ActSmartSync": mUIAutomationHelper.SmartSyncHandler((ActSmartSync)act); break; case "ActScreenShot": try { //TODO: When capturing all windows, we do showwindow. for few applications show window is causing applicaiton to minimize //Disabling the capturing all windows for Windows driver until we fix show window issue Bitmap bmp = mUIAutomationHelper.GetCurrentWindowBitmap(); act.AddScreenShot(bmp); //if not running well. need to add return same as PBDrive } catch (Exception ex) { act.Error = "Error: Action failed to be performed, Details: " + ex.Message; } break; case "Common.ActUIElement": HandleUIElementAction(act); break; case "ActBrowserElement": ActBrowserElement actWBE = (ActBrowserElement)act; HandleWindowsBrowserElementAction(actWBE); break; case "ActTableElement": ActTableElement actTable = (ActTableElement)act; HandleWindowsWidgetTableControlAction(actTable); break; default: throw new Exception("Action unknown/Not Impl in Driver - " + this.GetType().ToString()); } GC.Collect(); GC.WaitForPendingFinalizers(); } catch (System.Runtime.InteropServices.COMException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (ElementNotAvailableException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (ArgumentException e) { Reporter.ToLog(eLogLevel.ERROR, "Exception at Run action:" + act.GetType() + " Description:" + act.Description + " Error details:", e); CheckAndRetryRunAction(act, e); return; } catch (Exception e) { Reporter.ToLog(eLogLevel.WARN, "Exception at Run action", e); act.Error = e.Message; } }
public static void ClassInit(TestContext context) { WorkSpaceEventHandler WSEH = new WorkSpaceEventHandler(); WorkSpace.Init(WSEH); // launch PB Test App if (proc == null || proc.HasExited) { proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = @"pb_test_app.exe"; proc.StartInfo.WorkingDirectory = TestResources.GetTestResourcesFolder("PBTestApp"); Console.WriteLine(proc.StartInfo.WorkingDirectory); Console.WriteLine(proc.StartInfo.FileName); proc.Start(); GingerCore.General.DoEvents(); GingerCore.General.DoEvents(); } mGR = new GingerRunner(); mGR.CurrentSolution = new Ginger.SolutionGeneral.Solution(); mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test PB Driver"; Platform p = new Platform(); p.PlatformType = ePlatformType.PowerBuilder; mBF.TargetApplications.Add(new TargetApplication() { AppName = "PBTestAPP" }); Activity activity = new Activity(); activity.TargetApplication = "PBTestApp"; mBF.Activities.Add(activity); mBF.CurrentActivity = activity; mDriver = new PBDriver(mBF); mDriver.StartDriver(); Agent a = new Agent(); a.Active = true; a.Driver = mDriver; a.DriverType = Agent.eDriverType.PowerBuilder; mGR.SolutionAgents = new ObservableList <Agent>(); mGR.SolutionAgents.Add(a); ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "PBTestApp"; AA.Agent = a; mGR.ApplicationAgents.Add(AA); mGR.CurrentBusinessFlow = mBF; mGR.SetCurrentActivityAgent(); // Do Switch Window, to be ready for actions ActSwitchWindow c = new ActSwitchWindow(); c.LocateBy = eLocateBy.ByTitle; c.LocateValueCalculated = "Simple Page"; c.WaitTime = 10; mDriver.RunAction(c); //if(c.Status.Value==eRunStatus.Failed) //{ // c = new ActSwitchWindow(); // c.LocateBy = eLocateBy.ByTitle; // c.LocateValueCalculated = "Simple Page"; // c.WaitTime = 10; // mDriver.RunAction(c); //} ActPBControl action = new ActPBControl(); action.LocateBy = eLocateBy.ByXPath; action.ControlAction = ActPBControl.eControlAction.SetValue; action.AddNewReturnParams = true; action.Wait = 4; action.LocateValueCalculated = "/[AutomationId:1001]"; action.Value = proc.StartInfo.WorkingDirectory = TestResources.GetTestResourcesFolder("PBTestApp") + @"\Browser.html"; action.Active = true; mBF.CurrentActivity.Acts.Add(action); mBF.CurrentActivity.Acts.CurrentItem = action; //Act mGR.RunAction(action, false); action = new ActPBControl(); action.LocateBy = eLocateBy.ByName; action.ControlAction = ActPBControl.eControlAction.SetValue; action.LocateValueCalculated = "Launch Widget Window"; action.Active = true; mBF.CurrentActivity.Acts.Add(action); mBF.CurrentActivity.Acts.CurrentItem = action; //Act mGR.RunAction(action, false); c = new ActSwitchWindow(); c.LocateBy = eLocateBy.ByTitle; c.LocateValueCalculated = "CSM Widgets Test Applicaiton"; c.WaitTime = 10; mDriver.RunAction(c); string actual = ""; do { action = new ActPBControl(); action.LocateBy = eLocateBy.ByName; action.ControlAction = ActPBControl.eControlAction.IsExist; action.LocateValueCalculated = "Script Error"; action.AddNewReturnParams = true; action.Timeout = 10; action.Active = true; mBF.CurrentActivity.Acts.Add(action); mBF.CurrentActivity.Acts.CurrentItem = action; //Act mGR.RunAction(action, false); Assert.AreEqual(action.Status, eRunStatus.Passed, "Action Status"); actual = action.GetReturnParam("Actual"); if (actual.Equals("True")) { ActPBControl PbAct = new ActPBControl(); PbAct.LocateBy = eLocateBy.ByXPath; PbAct.ControlAction = ActPBControl.eControlAction.Click; PbAct.LocateValueCalculated = @"/Script Error/[LocalizedControlType:title bar]/Close"; PbAct.Active = true; mBF.CurrentActivity.Acts.Add(PbAct); mBF.CurrentActivity.Acts.CurrentItem = PbAct; mGR.RunAction(PbAct, false); } } while (actual.Equals("True")); //proceed for switch window and initialize browser c = new ActSwitchWindow(); c.LocateBy = eLocateBy.ByTitle; c.LocateValueCalculated = "CSM Widgets Test Applicaiton"; c.WaitTime = 2; mDriver.RunAction(c); int count = 1; ActBrowserElement actBrowser = new ActBrowserElement(); do { actBrowser.LocateBy = eLocateBy.ByXPath; actBrowser.LocateValue = @"/[AutomationId:1000]/[LocalizedControlType:pane]/[LocalizedControlType:pane]/[LocalizedControlType:pane]"; actBrowser.ControlAction = ActBrowserElement.eControlAction.InitializeBrowser; actBrowser.Wait = 2; actBrowser.Timeout = 10; actBrowser.Active = true; mBF.CurrentActivity.Acts.Add(actBrowser); mBF.CurrentActivity.Acts.CurrentItem = actBrowser; mGR.RunAction(actBrowser, false); count--; } while (actBrowser.Status.Equals(eRunStatus.Failed) && count > 0); if (actBrowser.Status.Equals(eRunStatus.Failed)) { Assert.AreEqual(actBrowser.Status, eRunStatus.Passed, "actBrowser.Status"); Assert.AreEqual(actBrowser.Error, null, "actBrowser.Error"); } }
public void SetUserAgentTest() { //arrange Activity activity = new Activity(); mBF.Activities.Add(activity); mBF.CurrentActivity = activity; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "DeviceEmulationUserAgent" }); mBF.CurrentActivity.TargetApplication = "DeviceEmulationUserAgent"; var mDriver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Chrome); mDriver.AutoDetect = true; mDriver.HttpServerTimeOut = 60; //Set Browser User Agent mDriver.BrowserUserAgent = "Mozilla/5.0 (iPad; CPU OS 11_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/11.0 Mobile/15A5341f Safari/604.1"; mDriver.BrowserHeight = "960"; mDriver.BrowserWidth = "600"; mDriver.StartDriver(); Agent agent = new Agent(); agent.Active = true; agent.Driver = mDriver; agent.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents.Add(agent); ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "DeviceEmulationUserAgent"; AA.Agent = agent; mGR.ApplicationAgents.Add(AA); mGR.CurrentBusinessFlow = mBF; mGR.CurrentBusinessFlow.CurrentActivity = activity; mGR.SetCurrentActivityAgent(); ActBrowserElement actBrowser = new ActBrowserElement(); actBrowser.ControlAction = ActBrowserElement.eControlAction.GotoURL; actBrowser.GetOrCreateInputParam("Value", "http://www.google.com"); actBrowser.Active = true; activity.Acts.Add(actBrowser); //act //get user agent string ActBrowserElement actBrowser2 = new ActBrowserElement(); actBrowser2.ControlAction = ActBrowserElement.eControlAction.RunJavaScript; actBrowser2.GetOrCreateInputParam("Value", "navigator.userAgent"); actBrowser2.Active = true; actBrowser2.AddNewReturnParams = true; activity.Acts.Add(actBrowser2); mGR.RunActivity(activity); //assert Assert.AreEqual(true, actBrowser2.ReturnValues.FirstOrDefault().Actual.Contains("iPad")); }
public void SetEmulationDeviceNameTest() { //arrange Activity activity = new Activity(); mBF.Activities.Add(activity); mBF.CurrentActivity = activity; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "DeviceEmulation" }); mBF.CurrentActivity.TargetApplication = "DeviceEmulation"; var mDriver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Chrome); mDriver.AutoDetect = true; mDriver.HttpServerTimeOut = 60; //Set emulation device name mDriver.EmulationDeviceName = "iPad"; mDriver.StartDriver(); Agent agent = new Agent(); agent.Active = true; agent.Driver = mDriver; agent.DriverType = Agent.eDriverType.SeleniumChrome; mGR.SolutionAgents.Add(agent); ApplicationAgent AA = new ApplicationAgent(); AA.AppName = "DeviceEmulation"; AA.Agent = agent; mGR.ApplicationAgents.Add(AA); mGR.CurrentBusinessFlow = mBF; mGR.CurrentBusinessFlow.CurrentActivity = activity; mGR.SetCurrentActivityAgent(); ActBrowserElement actBrowser = new ActBrowserElement(); actBrowser.ControlAction = ActBrowserElement.eControlAction.GotoURL; actBrowser.GetOrCreateInputParam("Value", "http://www.google.com"); actBrowser.Active = true; activity.Acts.Add(actBrowser); //act ActBrowserElement actBrowser2 = new ActBrowserElement(); actBrowser2.ControlAction = ActBrowserElement.eControlAction.RunJavaScript; actBrowser2.GetOrCreateInputParam("Value", "navigator.userAgent"); actBrowser2.Active = true; actBrowser2.AddNewReturnParams = true; activity.Acts.Add(actBrowser2); mGR.RunActivity(activity); //assert Assert.AreEqual(true, actBrowser2.ReturnValues.FirstOrDefault().Actual.Contains("iPad")); }
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); }