internal static List <ActUIElement.eElementAction> GetPlatformUIElementActionsList(ePlatformType Platform, eElementType ElementType) { PlatformInfoBase PB = GetPlatformImpl(Platform); return(PB.GetPlatformUIElementActionsList(ElementType)); }
internal static List <eLocateBy> GetPlatformUIElementLocatorsList(ePlatformType Platform) { PlatformInfoBase PB = GetPlatformImpl(Platform); return(PB.GetPlatformUIElementLocatorsList()); }
internal static List <string> GetPlatformUIElementPropertiesList(ePlatformType Platform, eElementType ElementType) { PlatformInfoBase PB = GetPlatformImpl(Platform); return(PB.GetPlatformUIElementPropertiesList(ElementType)); }
/// <summary> /// This method is used to convert the selected actions from the activity /// </summary> /// <param name="addNewActivity"></param> /// <param name="actionsToBeConverted"></param> /// <param name="convertToPOMAction"></param> /// <param name="selectedPOMObjectName"></param> /// <param name="currentActivity"></param> private void ConvertSelectedActionsFromActivity(BusinessFlowToConvert businessFlowToConvert, ObservableList <ConvertableActionDetails> actionsToBeConverted, bool addNewActivity, bool convertToPOMAction, ObservableList <Guid> selectedPOMObjectName, Activity currentActivity) { int actionIndex = 0; for (; actionIndex < currentActivity.Acts.Count(); actionIndex++) { Act act = (Act)currentActivity.Acts[actionIndex]; if (!mStopConversion) { try { ePlatformType activityPlatform = (from x in WorkSpace.Instance.Solution.ApplicationPlatforms where x.AppName == currentActivity.TargetApplication select x.Platform).FirstOrDefault(); if (act.Active && act is IObsoleteAction && (((IObsoleteAction)act).IsObsoleteForPlatform(activityPlatform)) && actionsToBeConverted.Where(a => a.SourceActionType == act.GetType() && a.Selected && a.TargetActionType == ((IObsoleteAction)act).TargetAction()).FirstOrDefault() != null) { // get the index of the action that is being converted int selectedActIndex = currentActivity.Acts.IndexOf(act); // convert the old action Act newAct = ((IObsoleteAction)act).GetNewAction(); if (newAct != null) { newAct.Platform = ((IObsoleteAction)act).GetTargetPlatform(); newAct.Description = newAct.Description;// string.Format("New - {0}", newAct.Description); if (convertToPOMAction && newAct.GetType().Name == ActUIElementClassName) { bool isFound = false; foreach (Guid pomOj in selectedPOMObjectName) { if (!isFound) { newAct = GetMappedElementFromPOMForAction(newAct, pomOj, ref isFound); } else if (isFound) { break; } } } currentActivity.Acts.Insert(selectedActIndex + 1, newAct); // set obsolete action in the activity as inactive act.Active = false; if (addNewActivity) { currentActivity.Acts.Remove(act); } businessFlowToConvert.ConvertedActionsCount++; } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to convert action", ex); } } else { break; } } }
/// <summary> /// This method is used to remove the Legacy actions from the businessFlows /// </summary> /// <param name="lst"></param> public void RemoveLegacyActionsHandler(ObservableList <BusinessFlowToConvert> lst) { int cleanedBfsCounter = 0; int cleanedActivitiesCounter = 0; int cleanedActionsCounter = 0; try { Reporter.ToStatus(eStatusMsgKey.CleaningLegacyActions); Parallel.ForEach(lst, businessFlowToConvert => { cleanedBfsCounter++; businessFlowToConvert.BusinessFlow.StartDirtyTracking(); for (int activityIndex = 0; activityIndex < businessFlowToConvert.BusinessFlow.Activities.Count; activityIndex++) { Activity activity = businessFlowToConvert.BusinessFlow.Activities[activityIndex]; ePlatformType activityPlatform = (from x in WorkSpace.Instance.Solution.ApplicationPlatforms where x.AppName == activity.TargetApplication select x.Platform).FirstOrDefault(); //if activity not active then check if all the actions are obsolete then remove the complete activity if (!activity.Active) { var count = activity.Acts.Where(act => (act is IObsoleteAction) && (((IObsoleteAction)act).IsObsoleteForPlatform(activityPlatform))).Count(); //Checks if the activity have all the action as obsolete then removes activity directly if (count == activity.Acts.Count) { businessFlowToConvert.BusinessFlow.Activities.RemoveAt(activityIndex); activityIndex--; cleanedActionsCounter = cleanedActionsCounter + count; cleanedActivitiesCounter++; continue; } } //check the actions if it is obsolete then remove the action for (int actIndex = 0; actIndex < activity.Acts.Count; actIndex++) { Act act = (Act)activity.Acts[actIndex]; if (((act.Active == false) && (act is IObsoleteAction) && (((IObsoleteAction)act).IsObsoleteForPlatform(activityPlatform)))) { activity.Acts.RemoveAt(actIndex); cleanedActionsCounter++; actIndex--; } } ////check if all the actions removed from activity the remove the activity //if (activity.Acts.Count <= 0 || activity.Acts.Where(x => x.Active == true).Count() <= 0) //{ // businessFlowToConvert.BusinessFlow.Activities.RemoveAt(activityIndex); // activityIndex--; //} } }); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error occurred during Legacy Actions cleanup", ex); } finally { Reporter.HideStatusMessage(); Reporter.ToUser(eUserMsgKey.LegacyActionsCleanup, cleanedBfsCounter, cleanedActivitiesCounter, cleanedActionsCounter); } }
public static List <eElementType> GetPlatformUIElementsList(ePlatformType Platform) { PlatformInfoBase PB = GetPlatformImpl(Platform); return(PB.GetPlatformUIElementsType()); }
public static BusinessFlow ConvertSeleniumScript(string FileName) { //TODO: move code from here to converter/import class var doc = new HtmlDocument(); Activity result = new Activity() { Active = true }; BusinessFlow bf = new BusinessFlow(""); ePlatformType actionsPlatform = ePlatformType.Web; try { //get the required platform for actions string selectedPlatform = ""; if (InputBoxWindow.OpenDialog("Required Platform", "Required platform (set 'Web' or 'Mobile'):", ref selectedPlatform)) { if (selectedPlatform.Trim().ToUpper() == "MOBILE") { actionsPlatform = ePlatformType.Mobile; } } doc.Load(FileName); result.ActivityName = doc.DocumentNode.Descendants("title").FirstOrDefault().InnerText; bf.Name = doc.DocumentNode.Descendants("title").FirstOrDefault().InnerText; List <HtmlNode> rows = doc.DocumentNode.Descendants("tbody").FirstOrDefault().Descendants() .Where(o => o.Name.StartsWith("tr")).ToList(); bf.Activities.Add(result); string action = ""; string locatevalue = ""; string value = ""; // string locby = ""; ActGenElement.eGenElementAction GenAction; eLocateBy locType = eLocateBy.ByXPath; foreach (HtmlNode row in rows) { if (row.Descendants("title").Count() > 0) { if (bf != null) { WorkSpace.Instance.SolutionRepository.AddRepositoryItem(bf); } bf = new BusinessFlow(row.Descendants("title").FirstOrDefault().InnerText); result = new Activity() { Active = true }; result.ActivityName = row.Descendants("title").FirstOrDefault().InnerText; bf.Activities.Add(result); } else { action = row.Descendants("td").ToList()[0].InnerText; locatevalue = row.Descendants("td").ToList()[1].InnerText.Replace("&", "&").Replace(">", ">"); value = row.Descendants("td").ToList()[2].InnerText; if (locatevalue.Trim().IndexOf("id=", StringComparison.CurrentCultureIgnoreCase) == 0 || locatevalue.Trim().IndexOf("id:=", StringComparison.CurrentCultureIgnoreCase) == 0) { locType = eLocateBy.ByID; locatevalue = locatevalue.Replace("id=", "").Replace("id:=", "");; } if (locatevalue.Trim().IndexOf("link=", StringComparison.CurrentCultureIgnoreCase) == 0 || locatevalue.Trim().IndexOf("LinkText:=", StringComparison.CurrentCultureIgnoreCase) == 0) { locType = eLocateBy.ByLinkText; locatevalue = locatevalue.Replace("link=", "").Replace("LinkText:=", ""); } if (locatevalue.Trim().IndexOf("css=", StringComparison.CurrentCultureIgnoreCase) == 0 || locatevalue.Trim().IndexOf("cssselector:=", StringComparison.CurrentCultureIgnoreCase) == 0) { locType = eLocateBy.ByCSS; locatevalue = locatevalue.Replace("css=", "").Replace("cssselector:=", ""); } if (locatevalue.Trim().IndexOf("/") == 0 || locatevalue.Trim().IndexOf("xpath", StringComparison.CurrentCultureIgnoreCase) == 0) { locType = eLocateBy.ByXPath; locatevalue = locatevalue.Replace("xpath=", "").Replace("xpath:=", "").Replace("xpath:", "").Trim(); } switch (action.ToUpper().Trim()) { case "OPEN": GenAction = ActGenElement.eGenElementAction.GotoURL; locType = eLocateBy.NA; locatevalue = ""; break; case "FCOMMONLAUNCHENVIRONMENT": GenAction = ActGenElement.eGenElementAction.GotoURL; locType = eLocateBy.NA; value = locatevalue; locatevalue = ""; break; case "TYPE": case "FCOMMONSETVALUEEDITBOX": GenAction = ActGenElement.eGenElementAction.SetValue; break; case "SELECT": case "FCOMMONSELECTIONOPTIONFROMLIST": GenAction = ActGenElement.eGenElementAction.SelectFromDropDown; break; case "FCOMMONJAVASCRIPTCLICK": GenAction = ActGenElement.eGenElementAction.Click; break; case "CLICKANDWAIT": case "CLICK": default: GenAction = ActGenElement.eGenElementAction.Click; break; } result.Acts.Add(new ActGenElement() { Active = true, Description = GenAction.ToString(), LocateBy = locType, LocateValue = locatevalue, GenElementAction = GenAction, Value = value, Platform = actionsPlatform }); } } if (bf != null) { return(bf); } } catch (Exception) { Reporter.ToUser(eUserMsgKey.ImportSeleniumScriptError); } return(null); }
private static DriverInfo GetDriver(ePlatformType platformType) { DriverInfo DI = new DriverInfo(platformType + " Driver"); if (platformType == ePlatformType.Web) { DI.services.Add(Agent.eDriverType.InternalBrowser); DI.services.Add(Agent.eDriverType.SeleniumChrome); DI.services.Add(Agent.eDriverType.SeleniumFireFox); DI.services.Add(Agent.eDriverType.SeleniumIE); DI.services.Add(Agent.eDriverType.SeleniumRemoteWebDriver); DI.services.Add(Agent.eDriverType.SeleniumEdge); } else if (platformType == ePlatformType.Java) { DI.services.Add(Agent.eDriverType.JavaDriver); } else if (platformType == ePlatformType.Mobile) { DI.services.Add(Agent.eDriverType.MobileAppiumAndroid); DI.services.Add(Agent.eDriverType.MobileAppiumIOS); DI.services.Add(Agent.eDriverType.PerfectoMobileAndroid); DI.services.Add(Agent.eDriverType.PerfectoMobileAndroidWeb); DI.services.Add(Agent.eDriverType.PerfectoMobileIOS); DI.services.Add(Agent.eDriverType.PerfectoMobileIOSWeb); DI.services.Add(Agent.eDriverType.MobileAppiumAndroidBrowser); DI.services.Add(Agent.eDriverType.MobileAppiumIOSBrowser); } else if (platformType == ePlatformType.Windows) { DI.services.Add(Agent.eDriverType.WindowsAutomation); } else if (platformType == ePlatformType.PowerBuilder) { DI.services.Add(Agent.eDriverType.PowerBuilder); } else if (platformType == ePlatformType.Unix) { DI.services.Add(Agent.eDriverType.UnixShell); } else if (platformType == ePlatformType.DOS) { DI.services.Add(Agent.eDriverType.DOSConsole); } else if (platformType == ePlatformType.WebServices) { DI.services.Add(Agent.eDriverType.WebServices); } //else if (platformType == ePlatformType.AndroidDevice.ToString()) //{ // DI.services.Add(Agent.eDriverType.AndroidADB); //} else if (platformType == ePlatformType.ASCF) { DI.services.Add(Agent.eDriverType.ASCF); } else if (platformType == ePlatformType.MainFrame) { DI.services.Add(Agent.eDriverType.MainFrame3270); } else { DI = null; } return(DI); }
private void SetPossibleAgentsGridData() { ObservableList <Agent> optionalAgents = new ObservableList <Agent>(); if (mApplicationAgent != null) { //find out the target application platform ApplicationPlatform ap = (from x in WorkSpace.Instance.Solution.ApplicationPlatforms where x.AppName == mApplicationAgent.AppName select x).FirstOrDefault(); if (ap != null) { ePlatformType appPlatform = ap.Platform; //get the solution Agents which match to this platform //List<Agent> optionalAgentsList = (from p in WorkSpace.Instance.Solution.Agents where p.Platform == appPlatform select p).ToList(); List <Agent> optionalAgentsList = (from p in WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Agent>() where p.Platform == appPlatform select p).ToList(); if (optionalAgentsList != null && mGingerRunner != null) { //remove already mapped agents List <IApplicationAgent> mappedApps = mGingerRunner.ApplicationAgents.Where(x => x.Agent != null).ToList(); foreach (ApplicationAgent mappedApp in mappedApps) { if (mappedApp.Agent.Platform == appPlatform && mappedApp != mApplicationAgent) { optionalAgentsList.Remove(mappedApp.Agent); } } foreach (Agent agent in optionalAgentsList) { optionalAgents.Add(agent); } } } } // FIXME : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Add Plugin agents // if (mApplicationAgent.target - plugin...) search based on type // Search plugins var list = from x in WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Agent>() where x.ServiceId == mApplicationAgent.AppName select x; foreach (Agent agent in list) { optionalAgents.Add(agent); } if (optionalAgents.Count == 0) { Reporter.ToUser(eUserMsgKey.NoOptionalAgent); } grdPossibleAgents.DataSourceList = optionalAgents; //select the current mapped agent in the list foreach (Agent agent in optionalAgents) { if (agent == mApplicationAgent.Agent) { grdPossibleAgents.Grid.SelectedItem = agent; } } }
/// <summary> /// Generates relevant Action and adds to the current/selected Activity /// </summary> /// <param name="mItem"> of type object and would successfully add an action with Act/ElementInfo/ApplicationModels type object is provided</param> /// <param name="mContext"> required to identify the currently selected Activity, Action is to be added to </param> public static int AddActionsHandler(object mItem, Context mContext, int targetIndex = -1) { Act instance = null; ePlatformType currentActivityPlatform = (from x in WorkSpace.Instance.Solution.ApplicationPlatforms where x.AppName == mContext.Activity.TargetApplication select x.Platform).FirstOrDefault(); if (mContext.Activity != null) { mContext.BusinessFlow.CurrentActivity = mContext.Activity;//so new Actions will be added to correct Activity } if (mItem is Act) { Act selectedAction = mItem as Act; if (!IsValidActionPlatformForActivity(selectedAction, mContext)) { Reporter.ToUser(eUserMsgKey.MissingTargetApplication, "Activity target platform is \"" + currentActivityPlatform + "\", where as action platform is \"" + selectedAction.Platform + "\"" + System.Environment.NewLine + "Please select same platform actions only."); return(-1); } if (!(selectedAction is ActWithoutDriver)) { selectedAction.Platform = (from x in WorkSpace.Instance.Solution.ApplicationPlatforms where x.AppName == mContext.Activity.TargetApplication select x.Platform).FirstOrDefault(); } instance = GenerateSelectedAction(selectedAction, mContext); } else if (mItem is ElementInfo) { ElementInfo elementInfo = mItem as ElementInfo; instance = GeneratePOMElementRelatedAction(elementInfo, mContext); } else if (mItem is ApplicationPOMModel) { ApplicationPOMModel currentPOM = mItem as ApplicationPOMModel; //required to show all the actions added as selected int updatedTargetIndex = targetIndex; foreach (ElementInfo elemInfo in currentPOM.MappedUIElements) { instance = GeneratePOMElementRelatedAction(elemInfo, mContext); if (instance != null) { instance.Active = true; if (updatedTargetIndex > -1) { mContext.Activity.Acts.Insert(updatedTargetIndex, instance); updatedTargetIndex++; } else { mContext.BusinessFlow.AddAct(instance, true); } } } mContext.Activity.Acts.CurrentItem = instance; instance = null; targetIndex = updatedTargetIndex; } else if (mItem is ApplicationAPIModel || mItem is RepositoryFolder <ApplicationAPIModel> ) { ObservableList <ApplicationAPIModel> apiModelsList = new ObservableList <ApplicationAPIModel>(); if (mItem is RepositoryFolder <ApplicationAPIModel> ) { apiModelsList = (mItem as RepositoryFolder <ApplicationAPIModel>).GetFolderItems(); apiModelsList = new ObservableList <ApplicationAPIModel>(apiModelsList.Where(a => a.TargetApplicationKey != null && Convert.ToString(a.TargetApplicationKey.ItemName) == mContext.Target.ItemName)); } else { apiModelsList.Add(mItem as ApplicationAPIModel); } AddApiModelActionWizardPage APIModelWizPage = new AddApiModelActionWizardPage(mContext, apiModelsList); WizardWindow.ShowWizard(APIModelWizPage); } if (instance != null) { instance.Active = true; if (instance is ActWithoutDriver) { instance.Platform = ePlatformType.NA; } else { instance.Platform = currentActivityPlatform; } if (targetIndex > -1) { mContext.Activity.Acts.Insert(targetIndex, instance); } else { mContext.BusinessFlow.AddAct(instance, true); } mContext.Activity.Acts.CurrentItem = instance; } return(targetIndex); }
bool IObsoleteAction.IsObsoleteForPlatform(ePlatformType platform) { // returning true as actswitchwindow is obsolete for all platform return(true); }
public bool IsObsoleteForPlatform(ePlatformType platform) { return(true); }
public ABPathInfo(ePlatformType type, string version) { OsType = type; Version = version; }
public ABPathInfo(ePlatformType osType) { OsType = osType; Version = string.Empty; }
private void SetVisibleControlsForAction() { ePlatformType ActivityPlatform = GetActionPlatform(); if (mAct.ControlAction == ActBrowserElement.eControlAction.SwitchFrame || mAct.ControlAction == ActBrowserElement.eControlAction.SwitchWindow || mAct.ControlAction == ActBrowserElement.eControlAction.CloseTabExcept) { LocateBy.Visibility = System.Windows.Visibility.Visible; ElementLocateByComboBox.Visibility = System.Windows.Visibility.Visible; LocateValue.Visibility = System.Windows.Visibility.Visible; LocateValueVE.Visibility = System.Windows.Visibility.Visible; Value.Visibility = System.Windows.Visibility.Collapsed; ValueUC.Visibility = System.Windows.Visibility.Collapsed; GotoURLRadioButton.Visibility = System.Windows.Visibility.Collapsed; Lable.Visibility = System.Windows.Visibility.Collapsed; ImplicitWait.Visibility = System.Windows.Visibility.Collapsed; ImplicitWaitVE.Visibility = System.Windows.Visibility.Collapsed; } else if (mAct.ControlAction == ActBrowserElement.eControlAction.GotoURL || mAct.ControlAction == ActBrowserElement.eControlAction.OpenURLNewTab || mAct.ControlAction == ActBrowserElement.eControlAction.InjectJS || mAct.ControlAction == ActBrowserElement.eControlAction.RunJavaScript) { if (mAct.ControlAction == ActBrowserElement.eControlAction.GotoURL || mAct.ControlAction == ActBrowserElement.eControlAction.OpenURLNewTab) { GotoURLRadioButton.Visibility = System.Windows.Visibility.Visible; Lable.Visibility = System.Windows.Visibility.Visible; Value.Content = "URL"; } else if (mAct.ControlAction == ActBrowserElement.eControlAction.InjectJS || mAct.ControlAction == ActBrowserElement.eControlAction.RunJavaScript) { Value.Content = "Script"; } LocateBy.Visibility = System.Windows.Visibility.Collapsed; ElementLocateByComboBox.Visibility = System.Windows.Visibility.Collapsed; LocateValue.Visibility = System.Windows.Visibility.Collapsed; LocateValueVE.Visibility = System.Windows.Visibility.Collapsed; Value.Visibility = System.Windows.Visibility.Visible; ValueUC.Visibility = System.Windows.Visibility.Visible; ImplicitWait.Visibility = System.Windows.Visibility.Collapsed; ImplicitWaitVE.Visibility = System.Windows.Visibility.Collapsed; } else { if (mAct.ControlAction == ActBrowserElement.eControlAction.InitializeBrowser) { if (!(ActivityPlatform == ePlatformType.Web)) { LocateBy.Visibility = System.Windows.Visibility.Visible; ElementLocateByComboBox.Visibility = System.Windows.Visibility.Visible; LocateValue.Visibility = System.Windows.Visibility.Visible; LocateValueVE.Visibility = System.Windows.Visibility.Visible; Value.Visibility = System.Windows.Visibility.Collapsed; ValueUC.Visibility = System.Windows.Visibility.Collapsed; GotoURLRadioButton.Visibility = System.Windows.Visibility.Collapsed; Lable.Visibility = System.Windows.Visibility.Collapsed; ImplicitWait.Visibility = System.Windows.Visibility.Visible; ImplicitWaitVE.Visibility = System.Windows.Visibility.Visible; } else { GotoURLRadioButton.Visibility = System.Windows.Visibility.Collapsed; Value.Visibility = System.Windows.Visibility.Collapsed; ValueUC.Visibility = System.Windows.Visibility.Collapsed; Lable.Visibility = System.Windows.Visibility.Collapsed; ImplicitWait.Visibility = System.Windows.Visibility.Collapsed; ImplicitWaitVE.Visibility = System.Windows.Visibility.Collapsed; } } else { LocateBy.Visibility = System.Windows.Visibility.Collapsed; ElementLocateByComboBox.Visibility = System.Windows.Visibility.Collapsed; LocateValue.Visibility = System.Windows.Visibility.Collapsed; LocateValueVE.Visibility = System.Windows.Visibility.Collapsed; Value.Visibility = System.Windows.Visibility.Collapsed; ValueUC.Visibility = System.Windows.Visibility.Collapsed; GotoURLRadioButton.Visibility = System.Windows.Visibility.Collapsed; Lable.Visibility = System.Windows.Visibility.Collapsed; ImplicitWait.Visibility = System.Windows.Visibility.Collapsed; ImplicitWaitVE.Visibility = System.Windows.Visibility.Collapsed; } } }
public static string GetVersionListFileName(ePlatformType osType) { string assetPath = GetVersionListPath(osType); return(AssetsCommon.BuildFileName(assetPath, PathConstant.FileName.VERSION_LIST)); }