private FireFox FindFireFox(Constraint findBy) { var clientPort = FireFox.GetClientPort(); clientPort.ConnectToExisting(); var ffBrowser = new FFBrowser(clientPort); var windowCount = ffBrowser.WindowCount; for (var i = 0; i < windowCount; i++) { ((FireFoxClientPort)ffBrowser.ClientPort).DefineDefaultJSVariablesForWindow(i); ffBrowser.ClientPort.InitializeDocument(); var firefox = CreateBrowserInstance(ffBrowser); if (firefox.Matches(findBy)) { return(firefox); } } clientPort.CloseConnection(); return(null); }