public void Stop() { Mara.Log("Cassini stopping ... "); _server.Stop(); //Mara.WaitForLocalPortToBecomeAvailable(Port); // meh Mara.Log("done"); }
// TODO I don't like using Mara.AppHost ... ? using something static feels icky? maybe? public void Visit(string path) { var url = (path.StartsWith("/")) ? (AppHost + path) : path; Mara.Log("Visit({0})", url); // The ChromeDriver hates life sometimes ... if (Browser == "chrome") { for (var i = 0; i < 10; i++) { if (TryToVisitInChrome(url)) { break; } else { Mara.Log("Chrome didn't want to visit {0} ... trying again ... ", url); System.Threading.Thread.Sleep(100); } } } else { webdriver.Navigate().GoToUrl(url); } }
void StopSeleniumStandalone() { if (_seleniumStandalone != null) { Mara.Log("Selenium Standalone stopping ... "); _seleniumStandalone.Kill(); Mara.WaitForLocalPortToBecomeAvailable(SeleniumServerPort); Mara.Log("done"); } }
IWebDriver InstantiateRemoteWebDriver(string browserName, string remote) { Mara.Log("InstantiateRemoteWebDriver({0}, {1})", browserName, remote); var capabilities = new DesiredCapabilities(browserName, string.Empty, new Platform(PlatformType.Any)); var remoteUri = new Uri(remote); // TODO add /wd/hub here so it doesn't have to be used everyplace else // Note: we might want to make it easy to get access to an HtmlUnit driver that does *NOT* execute // JavaScrpt *AND* one that *DOES* execute JavaScript for performance ... way faster tests? if (Environment.GetEnvironmentVariable("NO_JAVASCRIPT") == null) { capabilities.IsJavaScriptEnabled = true; // Run with JavaScript support, please! (Needed for HtmlUnit) } return(new RemoteWebDriver(remoteUri, capabilities)); }
void StartSeleniumStandalone() { Mara.Log("StartSeleniumStandalone"); _seleniumStandalone = new Process(); _seleniumStandalone.StartInfo.FileName = "java"; _seleniumStandalone.StartInfo.Arguments = string.Format("-jar {0} -port {1}", Path.GetFullPath(SeleniumServerJar), SeleniumServerPort); _seleniumStandalone.StartInfo.UseShellExecute = false; _seleniumStandalone.StartInfo.CreateNoWindow = true; // TODO document and test SELENIUM_LOG variable if (Environment.GetEnvironmentVariable("SELENIUM_LOG") == null) // if there's no SELENIUM_LOG variable, don't print STDOUT { _seleniumStandalone.StartInfo.RedirectStandardOutput = true; } Mara.Log("Selenium Standalone starting ... "); _seleniumStandalone.Start(); Mara.WaitForLocalPortToBecomeUnavailable(SeleniumServerPort, 100, 200); // 20 seconds max ... checking every 0.1 seconds Mara.Log("done"); }
IWebDriver InstantiateWebDriver() { Mara.Log("InstantiateWebDriver()"); Mara.Log(" Browser: {0}", Browser); Mara.Log(" Remote: {0}", Remote); Mara.Log(" RunSeleniumStandalone: {0}", RunSeleniumStandalone); if (RunSeleniumStandalone == true) { StartSeleniumStandalone(); } if (Remote == null) { return(InstantiateLocalWebDriver(Browser)); } else { return(InstantiateRemoteWebDriver(Browser, Remote)); } }
public void Start() { if (_started == true) { return; } _started = true; Mara.Log("XSP.Start()"); _server = new ApplicationServer(new XSPWebSource(IPAddress.Any, Port)); _server.AddApplicationsFromCommandLine(string.Format("{0}:/:{1}", Port, App)); Mara.Log("XSP2 starting ... "); try { _server.Start(true); } catch (SocketException ex) { // it gets mad sometimes? Mara.Log("SocketException while starting XSP: {0}", ex.Message); } Mara.WaitForLocalPortToBecomeUnavailable(Port); Mara.Log("done"); }
public void Start() { if (_started == true) { return; } _started = true; _server = new Microsoft.VisualStudio.WebHost.Server(Port, "/", App); Mara.Log("Cassini starting ... "); try { _server.Start(); } catch (SocketException ex) { //throw new Exception(string.Format("Couldn't start Cassini ... do you already have something running on port {0}?\n{1}", // Port, ex.Message)); Mara.Log("Cassini complained about something: {0}", ex.Message); } // Mara.WaitForLocalPortToBecomeUnavailable(Port); System.Threading.Thread.Sleep(3000); // it's not happy, let's just keep sleeping for now FIXME Mara.Log("done"); }
IWebDriver InstantiateLocalWebDriver(string browserName) { Mara.Log("InstantiateLocalWebDriver({0}) ...", browserName); switch (browserName) { case "chrome": return(new ChromeDriver()); case "firefox": return(new FirefoxDriver()); case "ie": //return new InternetExplorerDriver(); Mara.Log("launching IE ..."); var ie = new InternetExplorerDriver(); Mara.Log("launched? returning ..."); return(ie); default: throw new Exception("Unsupported browser: " + browserName); } }
public void Stop() { if (_server == null || _started == false) { return; } Mara.Log("XSP2 stopping ... "); try { _server.Stop(); Mara.Log("done"); } catch (InvalidOperationException ex) { if (ex.Message == "The server is not started.") { return; // this happens a lot? why ... } else { throw ex; } } // Mara.WaitForLocalPortToBecomeAvailable(Port); // meh, just kill this process ... it doesn't like to stop ... }
public XSP() { Mara.Log("Constructed a new XSP server"); }