/// <summary> /// Get New Window Handle /// </summary> /// <returns>Returns new window handle</returns> public string GetNewWindowTitle() { IWebDriver newtWindowHandle = null; string oldtWindowHandle = BaseDriver.CurrentWindowHandle; try { ReadOnlyCollection <string> windowHandles = BaseDriver.WindowHandles; if (windowHandles.Count > 1) { foreach (string handle in windowHandles) { if (handle != oldtWindowHandle) { newtWindowHandle = BaseDriver.SwitchTo().Window(handle); } } } else { newtWindowHandle = BaseDriver.SwitchTo().Window(oldtWindowHandle); } } catch (Exception e) { LogHandler.Error("SwitchToTab::NoSuchElementException - " + e.Message); throw new NoSuchElementException("SwitchToTab::" + e.Message); } return(newtWindowHandle.Title); }
/// <summary> /// /// </summary> /// <returns></returns> public IAlert SwitchToAlert() { try { WaitsHandler.WaitForAlert(BaseDriver, ""); return(BaseDriver.SwitchTo().Alert()); } catch (Exception e) { LogHandler.Error("SwitchToAlert::Exception - " + e.Message); throw new NoSuchElementException("SwitchToAlert::" + e.Message); } }
/// <summary> /// Switch to a different windows. /// </summary> /// <param name="title">the windows title</param> public IWebDriver SwitchToTab(string title) { IWebDriver currentWindowHandle = null; try { ReadOnlyCollection <string> windowHandles = BaseDriver.WindowHandles; foreach (string handle in windowHandles) { currentWindowHandle = BaseDriver.SwitchTo().Window(handle); if (currentWindowHandle.Url.ToLower().Contains(title.ToLower()) || currentWindowHandle.Title.ToLower().Contains(title.ToLower())) { return(BaseDriver.SwitchTo().Window(handle)); } } } catch (Exception e) { LogHandler.Error("SwitchToTab::NoSuchElementException - " + e.Message); throw new NoSuchElementException("SwitchToTab::" + e.Message); } return(BaseDriver); }
/// <summary> /// Check if Tab is present /// </summary> /// <param name="tabtitle">BTN number</param> /// <returns>true=if ihdcase tab is present; false=if it is not present</returns> public bool IsWindowPresent(string windowtitle) { WaitsHandler.WaitForAjaxToComplete(BaseDriver); IWebDriver currentWindowHandle = null; try { ReadOnlyCollection <string> windowHandles = BaseDriver.WindowHandles; foreach (string handle in windowHandles) { currentWindowHandle = BaseDriver.SwitchTo().Window(handle); if (currentWindowHandle.Url.ToLower().Contains(windowtitle.ToLower()) || currentWindowHandle.Title.ToLower().Contains(windowtitle.ToLower())) { return(true); } } } catch (Exception) { //logger } return(false); }
/// <summary> /// Moves to a particular iframe in the page. /// </summary> /// <param name="xpath">???</param> /// <returnsthe <see cref="IWebDriver"/>returns> public IWebDriver SwitchToDefaultContent() { return(BaseDriver.SwitchTo().DefaultContent()); }