/// <summary> /// Attempts to create a new browser. /// </summary> /// <remarks> /// The Firefox browser must have the "listen 6000" command run in the console to enable remote debugging. A newly created /// browser will not be able to connect until someone manually starts the remote debugger. /// </remarks> /// <returns> The browser instance. </returns> public static Browser Create() { // Create a new instance and return it. var application = Application.Create($"{Name}.exe", DebugArgument, false); var browser = new Firefox(application); browser.Connect(); browser.Refresh(); return(browser); }
/// <summary> /// Attempts to attach to an existing browser. /// </summary> /// <returns> The browser instance or null if not found. </returns> public static Browser Attach() { var application = Application.Attach(Name, null, false); if (application == null) { return(null); } var browser = new Firefox(application); browser.Connect(); browser.Refresh(); return(browser); }
/// <summary> /// Attempts to attach to an existing browser. /// </summary> /// <returns> The browser instance or null if not found. </returns> public static Browser Attach(Process process) { if (process.ProcessName != Name) { return(null); } if (!Application.Exists(Name, DebugArgument)) { throw new ArgumentException("The process was not started with the debug arguments.", nameof(process)); } var application = Application.Attach(process, false); var browser = new Firefox(application); browser.Connect(); browser.Refresh(); return(browser); }