/// <summary> /// Creates a firefox instance using a profile directory path /// </summary> /// <param name="profileDirectory">The path of the profile directory</param> /// <param name="cleanDirectory">Whether to clean the directory</param> /// <param name="driverSettings">Settings file for the Driver being instantiated.</param> /// <param name="performanceTimings">Whether to obtain performance timings for the browser.</param> public RatDriver(string profileDirectory, bool cleanDirectory, [Optional, DefaultParameterValue(null)] FirefoxSettings driverSettings, [Optional, DefaultParameterValue(false)] bool performanceTimings) { try { RecordPerformance = performanceTimings; if (performanceTimings) { InitialiseRatWatch(performanceTimings); } string driverType = typeof(TWebDriver).Name; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { GetProcesses(driverType, ProcessCollectionTime.InitialisationStart); } if (typeof(TWebDriver) == typeof(FirefoxDriver)) { EstablishDriverSettings(driverType); if (!_runTests) { throw new LiberatorOSException(_browserError); } FirefoxDriverControl controller = new FirefoxDriverControl(driverSettings); Driver = (TWebDriver)controller.StartDriverLoadProfileFromDisk(profileDirectory, cleanDirectory); WindowHandles.Add(Driver.CurrentWindowHandle, Driver.Title); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { GetProcesses(driverType, ProcessCollectionTime.InitialisationEnd); } } else { Console.Out.WriteLine("{0} does not currently allow the loading of profiles.", driverType); Console.Out.WriteLine("Please switch to Firefox if named profile loading is required"); } if (performanceTimings) { RatTimerCollection.StopTimer(EnumTiming.Instantiation); } } catch (Exception ex) { if (ex.GetType() != typeof(LiberatorOSException)) { Console.Out.WriteLine("An unexpected error has been detected."); } HandleErrors(ex); } }
/// <summary> /// Allows the specification of Firefox Driver settings /// </summary> /// <param name="firefoxSettings">The settings file to be used.</param> public FirefoxDriverControl(FirefoxSettings firefoxSettings) { if (firefoxSettings != null) { Firefox.AcceptUntrustedCertificates = firefoxSettings.AcceptUntrustedCertificates; Firefox.AlwaysLoadNoFocusLibrary = firefoxSettings.AlwaysLoadNoFocusLibrary; Firefox.AssumeUntrustedCertificateIssuer = firefoxSettings.AssumeUntrustedCertificateIssuer; Firefox.CleanProfile = firefoxSettings.CleanProfile; Firefox.CommunicationPort = firefoxSettings.ConnectToRunningBrowser; Firefox.ConnectToRunningBrowser = firefoxSettings.ConnectToRunningBrowser; Firefox.DeleteAfterUse = firefoxSettings.DeleteAfterUse; Firefox.EnableNativeEvents = firefoxSettings.EnableNativeEvents; Firefox.HideCommandPromptWindow = firefoxSettings.HideCommandPromptWindow; Firefox.Host = firefoxSettings.Host; Firefox.LogLevel = firefoxSettings.LogLevel; Firefox.Port = firefoxSettings.Port; Firefox.Preferences = firefoxSettings.Preferences; Firefox.ProfileDirectory = firefoxSettings.ProfileDirectory; Firefox.ProxyPreferences = firefoxSettings.ProxyPreferences; Firefox.SuppressInitialDiagnosticInformation = firefoxSettings.SuppressInitialDiagnosticInformation; Firefox.UseLegacyImplementation = firefoxSettings.UseLegacyImplementation; } }