/// <summary> /// Close the active tab /// </summary> public void CloseActiveTab() { try { string path = "//*[@id='tabsContainer']/li[@class='active']/span"; Driver.DriverManager.GetDriver().FindElement(By.XPath(path)).Click(); WaitsHandler.WaitForAjaxToComplete(baseDriver); } catch (Exception) { } }
/// <summary> /// Performs a Double Click operation on the specified element. /// </summary> /// <param name="eLocator"> String for element to locate </param> /// <param name="eType">Option for selection such as id / Xpath /..etc </param> public void DoubleClick(IWebElement element) { WaitsHandler.WaitForElementClickeable(BaseDriver, element, "", ""); try { new Actions(BaseDriver).DoubleClick(element).Perform(); LogHandler.Info("DoubleClick::The element has been double clicked"); } catch (Exception e) { LogHandler.Error("DoubleClick::Exception - " + e.Message); throw new NoSuchElementException("DoubleClick::Exception - " + e.Message); } WaitsHandler.WaitForAjaxToComplete(BaseDriver); }
/// <summary> /// This function perform Click operation on the specified element. /// </summary> /// <param name="element">IWebElement</param> public void Click(IWebElement element) { //Highlight(element); WaitsHandler.WaitForElementClickeable(BaseDriver, element, "", ""); try { element.Click(); LogHandler.Info("Click::The element has been clicked"); } catch (Exception e) { LogHandler.Error("Click::Exception - " + e.Message); throw new NoSuchElementException("Click::Exception - " + e.Message); } WaitsHandler.WaitForAjaxToComplete(BaseDriver); }
/// <summary> /// This function perform Click operation on the specified element after waiting for other element to be invisiable. /// </summary> /// <param name="element">IWebElement</param> public void ClickWait(IWebElement element, String locatorName, String locator) { //Highlight(element); WaitsHandler.WaitForElememntTobeInvisiable(BaseDriver, locatorName, locator, "", ""); try { element.Click(); LogHandler.Info("ClickWait::The element has been clicked"); } catch (Exception e) { LogHandler.Error("ClickWait::Exception - " + e.Message); throw new NoSuchElementException("Click::Exception - " + e.Message); } WaitsHandler.WaitForAjaxToComplete(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> /// Verifies the current page title. /// </summary> /// <param name="title"> String to check with page title</param> /// <returns> True if value is same else false</returns> public Boolean VerifyCurrentPageTitle(String title) { WaitsHandler.WaitForAjaxToComplete(DriverManager.GetDriver()); string value = null; string path = "//*[@id='tabsContainer']/li"; string active = "active"; //SleepHelper.Sleep(5); IList <IWebElement> tablist = DriverManager.GetDriver().FindElements(By.XPath(path)); foreach (var v in tablist) { if (active == v.GetAttribute("class")) { string actual_path = path + "[contains(@class, 'active')]/a"; value = DriverManager.GetDriver().FindElement(By.XPath(actual_path)).Text; if (value.ToUpper().Contains(title.ToUpper())) { return(true); } } } return(false); }
/// <summary> /// Accept Alert message /// </summary> /// <returns></returns> public void AcceptAlert() { SwitchToAlert().Accept(); WaitsHandler.WaitForAjaxToComplete(baseDriver); }
/// <summary> /// Default constructor. /// Use PageFactory to initialize web elements. /// </summary> /// <param name="Driver">the <see cref="IWebDriver"/></param> public BasePage(IWebDriver Driver) { BaseDriver = Driver; PageFactory.InitElements(BaseDriver, this); WaitsHandler.WaitForAjaxToComplete(BaseDriver); }