public void Redirect() { string currentUrl = GetCurrentUrl(); TestLog.Add("Redirecting to: " + currentUrl); _driver.Navigate().GoToUrl(currentUrl); }
/// <summary> /// Creates the and navigate to. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="webDriver">The web driver.</param> /// <param name="baseUrl">The base URL.</param> /// <param name="suppressLanguageParameter">Supresses the language parameter</param> /// <param name="hashTagParams">hash tag parameters</param> /// <param name="furtherUrlParameters"> /// The further URL param after the lng param. /// The example input value "cpn=2553 would navigate us to: www.hotel.de?lng=de&cpn=2553 /// </param> /// <returns>A PageObject, navigated to the PageUrl.</returns> public static T CreateAndNavigateTo <T>(IWebDriver webDriver, string baseUrl, bool suppressLanguageParameter = false, string[] hashTagParams = null, params string[] furtherUrlParameters) where T : BasePageObject { T pageObject = CreatePageObject <T>(webDriver); Type type = typeof(T); PagePropsAttribute pageAttribute = (PagePropsAttribute)type.GetCustomAttribute(typeof(PagePropsAttribute), true); string pageUrl = baseUrl; if (!pageUrl.EndsWith("/")) { pageUrl = pageUrl + "/"; } if (pageObject.PageSettings.IsSeoRoute) { pageUrl = CreateSeoRoute(pageUrl, pageAttribute, furtherUrlParameters); } else { pageUrl = CreateRoute(pageUrl, pageAttribute, suppressLanguageParameter, furtherUrlParameters); } if (hashTagParams != null) { pageUrl = string.Concat(pageUrl, "#?", string.Join("&", hashTagParams)); } TestLog.AddWithoutTime("<br><b>>>>" + type.Name + "</b>"); TestLog.Add("CreateAndNavigate: " + type.Name + " -> " + pageUrl); webDriver.Navigate().GoToUrl(pageUrl); return(pageObject); }
/// <summary> /// The cleaningfunction. Here we dispose things and close our driverconnections etc. /// </summary> /// <returns>Returning a empty string, or an errormessage.</returns> void ITestable.TeardownTest() { if (WebDriver != null) { WebDriver.Quit(); } TestLog.Add("Test ended at " + DateTime.Now); }
public string GetCurrentUrl() { Task <string> task = _asyncCalls.GetCurrentUrlTask(_driver); task.Wait(); string currentUrl = task.Result; TestLog.Add("Get current Url. " + currentUrl); return(currentUrl); }
public static T GetPageObjectByType <T>(IWebDriver webDriver, IDictionary <string, object> pageSettings = null) where T : BasePageObject { TestLog.AddWithoutTime("<br><b>>>>" + typeof(T).Name + "</b>"); TestLog.Add("GetPageObjectByType: " + typeof(T).Name); T pageObject = CreatePageObject <T>(webDriver); TestLog.Add("Applying Page settings for '" + pageObject.GetType().Name + "'"); ApplyPageSettings(pageObject, pageSettings ?? new Dictionary <string, object>()); TestLog.Add("Url is now: " + webDriver.Url); return(pageObject); }
/// <summary> /// Creates the and navigate to. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="webDriver">The web driver.</param> /// <param name="baseUrl">The base URL.</param> /// <param name="pageSettings">The page settings</param> /// <param name="furtherUrlParameters"></param> /// <returns>A PageObject, navigated to the PageUrl.</returns> public static T CreateAndNavigateTo <T>(IWebDriver webDriver, string baseUrl, IDictionary <string, object> pageSettings = null, params string[] furtherUrlParameters) where T : BasePageObject { T pageObject = CreatePageObject <T>(webDriver); String pageUrl = baseUrl; if (!pageUrl.EndsWith("/")) { pageUrl = pageUrl + "/"; } pageUrl = pageUrl + pageObject.CreatePageUrlWithParameters(furtherUrlParameters); TestLog.AddWithoutTime("<br><b>>>>" + typeof(T).Name + "</b>"); TestLog.Add("CreateAndNavigate: " + typeof(T).Name + " -> " + pageUrl); webDriver.Navigate().GoToUrl(pageUrl); TestLog.Add("Url is now: " + webDriver.Url); ApplyPageSettings(pageObject, pageSettings ?? new Dictionary <string, object>()); return(pageObject); }
private static T CreatePageObject <T>(IWebDriver webDriver) where T : BasePageObject { try { T pageObject = (T)Activator.CreateInstance(typeof(T), webDriver, PageSettingsFactory); InitElements(webDriver, pageObject); TestLog.Add("Applying Page settings for '" + pageObject.GetType().Name + "'"); pageObject.PageSettings.ApplySettings(); return(pageObject); } catch (TargetInvocationException exception) { if (exception.InnerException != null) { throw exception.InnerException; } throw; } }
public static T GetPageObjectByType <T>(IWebDriver webDriver) where T : BasePageObject { TestLog.AddWithoutTime("<br><b>>>>" + typeof(T).Name + "</b>"); TestLog.Add("GetPageObjectByType: " + typeof(T).Name); return(CreatePageObject <T>(webDriver)); }
public void WaitForElementNotDisplayed(BasicPageElement element) { TestLog.Add("WaitForElementNotDisplayed: " + element.By); _driver.WaitForElement(element.By, Visibility.Hidden); }
public ReadOnlyCollection <IWebElement> WaitAndFindElements(By findBy) { TestLog.Add("WaitAndFindElements: " + findBy); return(_driver.WaitForElements(findBy)); }
public IWebElement WaitAndFindElement(By findBy) { TestLog.Add("WaitAndFindElement: " + findBy); return(_driver.WaitForElement(findBy)); }
/// <summary> /// Waits for an element to get visible. /// </summary> /// <param name="element">the element</param> /// <param name="timeout">A optional custom timeoutInSeconds (how long should we wait?)</param> public void WaitForElementDisplayed(BasicPageElement element, TimeSpan?timeout = null) { TestLog.Add("WaitForElementDisplayed: " + element.By); _driver.WaitForElement(element.By, timeout: timeout); }
/// <summary> /// Close the tab which has the focus of the Webdriver instance /// </summary> public void CloseCurrentTab() { TestLog.Add("Closing Current Tab."); _driver.Close(); }