//Adding check that Registry values exist //FEATURE_BROWSER_EMULATION- Defines in which document mode WebBrowser Control(Internal browser) should launch (IE 11 ) //FEATURE_SCRIPTURL_MITIGATION - feature allows the href attribute of a objects to support the javascript prototcol. // It is by default disabled for WebBrowser Control and enabled for IE public static void CheckRegistryValues() { bool osBitTypeIs64 = false; string appExeName = string.Empty; string registryKeyPath = string.Empty; string requiredValueName = string.Empty; object requiredValue = string.Empty; try { //Find out the OS bit type osBitTypeIs64 = Environment.Is64BitOperatingSystem; //Get the App name appExeName = System.AppDomain.CurrentDomain.FriendlyName; //######################## FEATURE_BROWSER_EMULATION ########################### if (osBitTypeIs64) { registryKeyPath = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"; } else { registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"; } requiredValueName = appExeName; requiredValue = string.Empty; object installedIEVersion = RegistryFunctions.GetRegistryValue(eRegistryRoot.HKEY_LOCAL_MACHINE, @"Software\Microsoft\Internet Explorer", "svcUpdateVersion"); if (installedIEVersion != null) { if (installedIEVersion != null) { requiredValue = (installedIEVersion.ToString().Split(new char[] { '.' }))[0] + "000"; } } if (requiredValue.ToString() == string.Empty || requiredValue.ToString() == "000") { requiredValue = "11000"; //defualt value } //write registry key to the User level if failed to write to Local Machine level if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_LOCAL_MACHINE, registryKeyPath, requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true)) { //Try User Level registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"; if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_CURRENT_USER, registryKeyPath, requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true)) { Reporter.ToLog(eLogLevel.ERROR, "Failed to add the required registry key 'FEATURE_BROWSER_EMULATION' value to both Local Machine and User level"); } } //End //######################## FEATURE_SCRIPTURL_MITIGATION ########################### if (osBitTypeIs64) { registryKeyPath = @"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION"; } else { registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION"; } requiredValueName = appExeName; requiredValue = 1; //write registry key to the User level if failed to write to Local Machine level if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_LOCAL_MACHINE, registryKeyPath, requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true)) { //Try User Level registryKeyPath = @"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_SCRIPTURL_MITIGATION"; if (!RegistryFunctions.CheckRegistryValueExist(eRegistryRoot.HKEY_CURRENT_USER, registryKeyPath, requiredValueName, requiredValue, Microsoft.Win32.RegistryValueKind.DWord, true, true)) { Reporter.ToLog(eLogLevel.ERROR, "Failed to add the required registry key 'FEATURE_SCRIPTURL_MITIGATION' value to both Local Machine and User level"); } } //End } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Failed to complete the registry values check", ex); Reporter.ToUser(eUserMsgKey.RegistryValuesCheckFailed); } }
public void SetDriverConfiguration() { if (Agent.DriverConfiguration == null) { return; } if (Agent.ProjEnvironment == null) { Agent.ProjEnvironment = new Environments.ProjEnvironment();//to avoid value expertion exception } if (Agent.BusinessFlow == null) { Agent.BusinessFlow = new GingerCore.BusinessFlow();//to avoid value expertion exception } ValueExpression ve = new ValueExpression(Agent.ProjEnvironment, Agent.BusinessFlow, Agent.DSList); if (Agent.AgentType == Agent.eAgentType.Service) { SetServiceConfiguration(); } else { Agent.DriverClass = TargetFrameworkHelper.Helper.GetDriverType(Agent); SetDriverMissingParams(Agent.DriverClass); foreach (DriverConfigParam DCP in Agent.DriverConfiguration) { string value = null; ObservableList <DriverConfigParam> multiValues = null; //process Value expression in case used if (DCP.MultiValues != null) { multiValues = new ObservableList <DriverConfigParam>(); foreach (DriverConfigParam subValue in DCP.MultiValues) { ve.Value = subValue.Value; multiValues.Add(new DriverConfigParam() { Parameter = subValue.Parameter, Value = ve.ValueCalculated }); } } else { ve.Value = DCP.Value; value = ve.ValueCalculated; } PropertyInfo driverProp = Driver.GetType().GetProperty(DCP.Parameter); if (driverProp != null) { //set multi values prop if (DCP.MultiValues != null) { Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, multiValues); continue; } //set eNum prop UserConfiguredEnumTypeAttribute enumTypeConfig = null; try { MemberInfo[] mf = Driver.GetType().GetMember(DCP.Parameter); if (mf != null) { enumTypeConfig = Attribute.GetCustomAttribute(mf[0], typeof(UserConfiguredEnumTypeAttribute), false) as UserConfiguredEnumTypeAttribute; if (enumTypeConfig != null) { Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, Enum.Parse(enumTypeConfig.EnumType, value)); continue; } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.WARN, string.Format("Failed to check if the driver configuration '{0}' is from EnumType", DCP.Parameter), ex); } //set standard prop types string driverPropType = driverProp.PropertyType.Name; switch (driverPropType) { case "String": Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, value); break; case "Boolean": try { Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, Convert.ToBoolean(value)); } catch (Exception) { Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, true); } break; case "Int32": Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, int.Parse(value)); break; default: Reporter.ToUser(eUserMsgKey.SetDriverConfigTypeNotHandled, DCP.GetType().ToString()); Reporter.ToLog(eLogLevel.ERROR, string.Format("The driver configuration '{0}' field type '{1}' is unknown", DCP.Parameter, driverPropType)); break; } } else { Reporter.ToLog(eLogLevel.DEBUG, string.Format("The driver configuration '{0}' was not found on the driver class", DCP.Parameter)); } } Driver.AdvanceDriverConfigurations = Agent.AdvanceAgentConfigurations; } }
private void SetDriverConfiguration() { Boolean bValue; if (DriverConfiguration == null) { return; } if (ProjEnvironment == null) { ProjEnvironment = new Environments.ProjEnvironment();//to avoid value expertion exception } if (BusinessFlow == null) { BusinessFlow = new GingerCore.BusinessFlow();//to avoid value expertion exception } foreach (DriverConfigParam DCP in DriverConfiguration) { //process Value expression in case used ValueExpression VE = new ValueExpression(ProjEnvironment, BusinessFlow, DSList); VE.Value = DCP.Value; string value = VE.ValueCalculated; //TODO: check if Convert.To is better option //TODO: hanlde other feilds type PropertyInfo tp = Driver.GetType().GetProperty(DCP.Parameter); if (tp != null) { string tpName = tp.PropertyType.Name; switch (tpName) { case "String": Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, value); break; case "Boolean": try { bValue = Convert.ToBoolean(value); } catch (Exception) { bValue = true; } Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, bValue); break; case "Int32": int i = int.Parse(value); Driver.GetType().GetProperty(DCP.Parameter).SetValue(Driver, i); break; case "eType": //TODO: Handle enums later... throw new Exception("Driver Config - Enum not supported yet"); default: Reporter.ToUser(eUserMsgKeys.SetDriverConfigTypeNotHandled, DCP.GetType().ToString()); break; } } else { // TODO: show message to user to remove param - old } } Driver.AdvanceDriverConfigurations = this.AdvanceAgentConfigurations; }
public void StartDriver() { mIsStarting = true; OnPropertyChanged(Fields.Status); try { try { if (Remote) { throw new Exception("Remote is Obsolete, use GingerGrid"); //We pass the agent info } else { switch (DriverType) { case eDriverType.InternalBrowser: Driver = new InternalBrowser(BusinessFlow); break; case eDriverType.SeleniumFireFox: Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.FireFox); break; case eDriverType.SeleniumChrome: Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Chrome); break; case eDriverType.SeleniumIE: Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.IE); break; case eDriverType.SeleniumRemoteWebDriver: Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.RemoteWebDriver); // set capabilities if (DriverConfiguration == null) { DriverConfiguration = new ObservableList <DriverConfigParam>(); } ((SeleniumDriver)Driver).RemoteGridHub = GetParamValue(SeleniumDriver.RemoteGridHubParam); ((SeleniumDriver)Driver).RemoteBrowserName = GetParamValue(SeleniumDriver.RemoteBrowserNameParam); ((SeleniumDriver)Driver).RemotePlatform = GetParamValue(SeleniumDriver.RemotePlatformParam); ((SeleniumDriver)Driver).RemoteVersion = GetParamValue(SeleniumDriver.RemoteVersionParam); break; case eDriverType.SeleniumEdge: Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.Edge); break; case eDriverType.SeleniumPhantomJS: Driver = new SeleniumDriver(GingerCore.Drivers.SeleniumDriver.eBrowserType.PhantomJS); break; case eDriverType.ASCF: Driver = new ASCFDriver(BusinessFlow, Name); break; case eDriverType.DOSConsole: Driver = new DOSConsoleDriver(BusinessFlow); break; case eDriverType.UnixShell: Driver = new UnixShellDriver(BusinessFlow, ProjEnvironment); ((UnixShellDriver)Driver).SetScriptsFolder(SolutionFolder + @"\Documents\sh\"); break; case eDriverType.MobileAppiumAndroid: Driver = new SeleniumAppiumDriver(SeleniumAppiumDriver.eSeleniumPlatformType.Android, BusinessFlow); break; case eDriverType.MobileAppiumIOS: Driver = new SeleniumAppiumDriver(SeleniumAppiumDriver.eSeleniumPlatformType.iOS, BusinessFlow); break; case eDriverType.MobileAppiumAndroidBrowser: Driver = new SeleniumAppiumDriver(SeleniumAppiumDriver.eSeleniumPlatformType.AndroidBrowser, BusinessFlow); break; case eDriverType.MobileAppiumIOSBrowser: Driver = new SeleniumAppiumDriver(SeleniumAppiumDriver.eSeleniumPlatformType.iOSBrowser, BusinessFlow); break; case eDriverType.PerfectoMobile: Driver = new PerfectoDriver(BusinessFlow); break; case eDriverType.WebServices: WebServicesDriver WebServicesDriver = new WebServicesDriver(BusinessFlow); Driver = WebServicesDriver; break; case eDriverType.WindowsAutomation: Driver = new WindowsDriver(BusinessFlow); break; case eDriverType.FlaUIWindow: Driver = new WindowsDriver(BusinessFlow, UIAutomationDriverBase.eUIALibraryType.FlaUI); break; case eDriverType.PowerBuilder: Driver = new PBDriver(BusinessFlow); break; case eDriverType.FlaUIPB: Driver = new PBDriver(BusinessFlow, UIAutomationDriverBase.eUIALibraryType.FlaUI); break; case eDriverType.JavaDriver: Driver = new JavaDriver(BusinessFlow); break; case eDriverType.MainFrame3270: Driver = new MainFrameDriver(BusinessFlow); break; case eDriverType.AndroidADB: string DeviceConfigFolder = GetOrCreateParam("DeviceConfigFolder").Value; if (!string.IsNullOrEmpty(DeviceConfigFolder)) { Driver = new AndroidADBDriver(BusinessFlow, SolutionFolder + @"\Documents\Devices\" + DeviceConfigFolder + @"\"); } else { //TODO: Load create sample folder/device, or start the wizard throw new Exception("Please set device config folder"); } break; //TODO: default mess } } } catch (Exception e) { Reporter.ToUser(eUserMsgKeys.FailedToConnectAgent, Name, e.Message); } Driver.BusinessFlow = this.BusinessFlow; SetDriverConfiguration(); //if STA we need to start it on seperate thread, so UI/Window can be refreshed: Like IB, Mobile, Unix if (Driver.IsSTAThread()) { CTS = new CancellationTokenSource(); MSTATask = new Task(() => { Driver.StartDriver(); }, CTS.Token, TaskCreationOptions.LongRunning); MSTATask.Start(); } else { Driver.StartDriver(); } } finally { // Give the driver time to start Thread.Sleep(500); mIsStarting = false; Driver.IsDriverRunning = true; OnPropertyChanged(Fields.Status); Driver.driverMessageEventHandler += driverMessageEventHandler; OnPropertyChanged(Fields.IsWindowExplorerSupportReady); } }
public bool ImportActivitiesGroupActivitiesFromRepository(ActivitiesGroup activitiesGroup, ObservableList <Activity> activitiesRepository, bool inSilentMode = true, bool keepOriginalTargetApplicationMapping = false, Activity indexActivity = null) { string missingActivities = string.Empty; if (activitiesGroup != null && activitiesGroup.ActivitiesIdentifiers.Count == 0) { return(true); } //import Activities if (activitiesGroup != null && activitiesRepository != null) { foreach (ActivityIdentifiers actIdent in activitiesGroup.ActivitiesIdentifiers) { Activity repoAct = activitiesRepository.Where(x => x.ActivityName == actIdent.ActivityName && x.Guid == actIdent.ActivityGuid).FirstOrDefault(); if (repoAct == null) { repoAct = activitiesRepository.Where(x => x.Guid == actIdent.ActivityGuid).FirstOrDefault(); } if (repoAct == null) { repoAct = activitiesRepository.Where(x => x.ActivityName == actIdent.ActivityName).FirstOrDefault(); } if (repoAct != null) { Activity actInstance = (Activity)repoAct.CreateInstance(true); actInstance.ActivitiesGroupID = activitiesGroup.Name; if (keepOriginalTargetApplicationMapping == false) { SetActivityTargetApplication(actInstance); } if (indexActivity == null && ActivitiesGroups.Count > 1) { this.AddActivity(actInstance, (CurrentActivity != null), CurrentActivity); } else { this.AddActivity(actInstance, (CurrentActivity != null), indexActivity); } actIdent.IdentifiedActivity = actInstance; indexActivity = actInstance; } else { missingActivities += "'" + actIdent.ActivityName + "', "; } } //notify on missing activities if (missingActivities != string.Empty && inSilentMode == false) { missingActivities = missingActivities.TrimEnd(new char[] { ',', ' ' }); Reporter.ToUser(eUserMsgKeys.PartOfActivitiesGroupActsNotFound, missingActivities); return(false); } else { return(true); } } if (inSilentMode == false) { Reporter.ToUser(eUserMsgKeys.ActivitiesGroupActivitiesNotFound); } return(false); }
public bool WarnFromMissingVariablesUse(ObservableList <VariableBase> solutionVars, ObservableList <VariableBase> bfVars, bool silentMode = true, bool autoAddMissingVars = true) { List <string> usedVariables = new List <string>(); foreach (Act action in this.Acts) { VariableBase.GetListOfUsedVariables(action, ref usedVariables); } for (int indx = 0; indx < usedVariables.Count; indx++) { if (this.Variables.Where(x => x.Name == usedVariables[indx]).FirstOrDefault() != null) { usedVariables.RemoveAt(indx); indx--; } } if (usedVariables.Count > 0) { string missingVars = string.Empty; foreach (string var in usedVariables) { missingVars += "'" + var + "',"; } missingVars = missingVars.TrimEnd(new char[] { ',' }); if (!silentMode) { if (Reporter.ToUser(eUserMsgKeys.WarnRegradingMissingVariablesUse, ActivityName, missingVars) == MessageBoxResult.Yes) { autoAddMissingVars = true; } else { autoAddMissingVars = false; } } if (autoAddMissingVars) { //add missing vars from bf / global vars for (int indx = 0; indx < usedVariables.Count; indx++) { VariableBase var = bfVars.Where(x => x.Name == usedVariables[indx]).FirstOrDefault(); if (var == null) { var = solutionVars.Where(x => x.Name == usedVariables[indx]).FirstOrDefault(); } if (var != null) { this.Variables.Add(var); usedVariables.RemoveAt(indx); indx--; } } if (usedVariables.Count > 0) { //not all vars were found and added automatically if (!silentMode) { Reporter.ToUser(eUserMsgKeys.NotAllMissingVariablesWereAdded, missingVars); } return(true);//not all missing vars were added automatically } else { return(false);//missing vars were added automatically } } else { return(true); //not auto adding the missing vars } } return(false); //no missing vars }