/// <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> /// Gets current value of Kendo ComboDropdown /// </summary> /// <param name="ele">IWebElement Kendo ComboDropDown</param> /// <returns>Current selected value of the combo</returns> public static string GetCurrentValueofComboDropdown(this IWebElement ele) { CheckDom(); ele.DrawHighlight(); var x = WebDriverFactory.LastDriver .FindElement(CustomBy.jQuery( $"(\"#{ele.GetAttribute("aria-owns").Replace("_listbox", "_option_selected")}\")")); //By.Id($"{ele.GetAttribute("aria-owns").Replace("_listbox", "_option_selected")}"); return WebDriverFactory.LastDriver .FindElement(CustomBy.jQuery($"(\"#{ele.GetAttribute("aria-owns").Replace("_listbox", "_option_selected")}\")")).GetClass().Contains("k-state-selected") ? WebDriverFactory.LastDriver .FindElement(CustomBy.jQuery($"(\"#{ele.GetAttribute("aria-owns").Replace("_listbox", "_option_selected")}\")")).GetAttribute("innerHTML") : string.Empty; }