/// <summary> /// Asserts that the specified browser's current URL ends with a specific string. /// Start your expectedEndOfUrl with a '/' for maximum accuracy. /// </summary> /// <param name="browser">The browser to check.</param> /// <param name="expectedEndOfUrl">What you expect the URL to end with.</param> public static void CurrentUrlEndsWith(HttpClient browser, string expectedEndOfUrl) { Uri url = browser.CurrentUrl; string urlString = url.AbsoluteUri; string errorMessage = string.Format("End of current URL:\nExpected: '{0}'\nWas: '{1}'", expectedEndOfUrl, urlString); True(urlString.EndsWith(expectedEndOfUrl), errorMessage); }
/// <summary> /// The method can be used for NUnitAsp testing of WebForms. /// It uses the NUnitASP browser to request pages. /// </summary> /// <param name="relativePath">Allow the relative path to be specified.</param> /// <param name="Browser">NUnitASP Browser object</param> public void RequestNUnitASPPage(string relativePath, HttpClient Browser) { string server; //local.bbc.co.uk could not be resolved by Browser.GetPage() - not sure why. server = _server.Host; server = server.Replace("local.bbc.co.uk", "localhost"); relativePath = AddDebugUserParams(relativePath); //Specifying the actual aspx page can be important so that NUNitASP click events are processed correctly. Uri URL = new Uri("http://" + server + relativePath); //Set editor credentials if (_useEditorAuthentication) { NetworkCredential myCred = new NetworkCredential("editor", "editor"); CredentialCache MyCrendentialCache = new CredentialCache(); MyCrendentialCache.Add(URL, "Basic", myCred); Browser.Credentials = MyCrendentialCache; } if (_cookie.Length >= 66) { Console.WriteLine("Adding cookie: " + _cookie); // Create and add the cookie to the request Cookie cookie; if (_useIdentity) { cookie = new Cookie("IDENTITY", _cookie, "/", server); } else { cookie = new Cookie("SSO2-UID", _cookie, "/", server); } Browser.Cookies.Add(cookie); } foreach (Cookie cookie in _cookieList) { Browser.Cookies.Add(cookie); } // Check to see if we require a proxy for the request if (_useProxyPassing && CurrentWebProxy != null) { Console.WriteLine("Using proxy"); // Set the proxy Browser.Proxy = CurrentWebProxy; } else { Browser.Proxy = null; } Console.WriteLine("NunitASP Browser getting page :" + URL.AbsoluteUri); Browser.GetPage(URL.AbsoluteUri); }
/// <summary> /// Create the tester and link it to an ASP.NET web form. /// </summary> /// <param name="browser">The browser used to load this page.</param> public WebFormTester(HttpClient browser) { this.browser = browser; }
public WebFormTester(string aspId, HttpClient browser) { this.aspId = aspId; this.browser = browser; }
/// <summary> /// Obsolete; use WebFormTester instead. /// </summary> public WebForm(HttpClient browser) : base(browser) { }