/// <summary> /// Change to tab/subtab specified /// </summary> /// <param name="tab">name of top level tab</param> /// <param name="dropDownItem">name of submenu item</param> public static void ChangeTab(string tab, string dropDownItem = null) { //locate the tab link and click it WaitHelpers.WaitForElementVisible(By.CssSelector(".nav.top-tab-bar")); WaitHelpers.WaitForClickable(By.CssSelector(".nav.top-tab-bar")); IWebElement tabStrip = WebDriverFactory.LastDriver.FindElement(By.CssSelector(".nav.top-tab-bar")); var xpathLocator = $"//a[descendant::div[contains(@id,\"DetailView_{tab}\")]] | //a[descendant::div[contains(@id,'DetailView_') and contains(.,\"{tab}\")]]"; WaitHelpers.WaitForElementVisible(By.XPath(xpathLocator)); IWebElement tabToClick = WaitHelpers.WaitForClickable(tabStrip.FindElement(By.XPath(xpathLocator))); WaitHelpers.ExplicitWait(); tabToClick.Click(); //if drop-down, click the drop-down item if (!string.IsNullOrEmpty(dropDownItem)) { //IWebElement element = WebDriverFactory.LastDriver.ExecuteJavaScript<IWebElement>("return $" + "(\"a:has(div:contains(\'Demographics\'))\").filter(\":visible\")" + ".get(0)"); //element.DrawHighlight(); //var els = tabToClick.FindElements(By.XPath($"//a[descendant::div[contains(.,\"{dropDownItem}\")]]")); //foreach (var e in els) //{ // if (e.Displayed) { e.Click(); } //} //IWebElement dropDownToClick = WaitHelpers.WaitForClickable(tabToClick.FindElement(By.XPath($"//a[descendant::div[contains(.,\"{dropDownItem}\")]]"))); //dropDownToClick.Click(); WebDriverFactory.LastDriver.FindElement(CustomBy.jQuery($"(\"a:has(div:contains(\'{dropDownItem}\'))\").filter(\":visible\")")).Click(); } WaitHelpers.WaitForAjaxLoad(); }
/// <summary> /// Force text into Kendo DropDownCombo input. /// </summary> /// <param name="ele">IWebElement input</param> /// <param name="text">text to input</param> private static void ForceTextToListInput(this IWebElement ele, string text)//ToDo: remove sleeps once Netlag is fixed - dg 03/14/17 { WaitHelpers.ExplicitWait(200); WaitHelpers.WaitForAjaxLoad(); WaitHelpers.ExplicitWait(100); ele.Click(); WaitHelpers.ExplicitWait(100); ele.Clear(); WaitHelpers.ExplicitWait(100); ele.SendKeys(text); WaitHelpers.ExplicitWait(100); ele.SendKeys(Keys.Tab); WaitHelpers.ExplicitWait(100); }