public void SearchVerification() { Thread.Sleep(2000); myManager.ActiveBrowser.WaitUntilReady(); myManager.ActiveBrowser.RefreshDomTree(); ObjSearch search = new ObjSearch(myManager); HtmlUnorderedList list = search.SearchFilters.As <HtmlUnorderedList>(); foreach (HtmlListItem item in list.AllItems) { string text = item.InnerText; Match match = Regex.Match(text, @"(.*)(\([0-9]*\))", RegexOptions.IgnoreCase); if (match.Success) { var data = Regex.Match(text, @"\d+").Value; //filter the count string lableName = match.Groups[1].Value; //filter the name int val; if (int.TryParse(data, out val)) { if (val > 0) { if (lableName != "All") { lableName = ReturnNames(lableName.ToUpper()); HtmlInputCheckBox checkbox = item.Find.AllByTagName("input")[0].As <HtmlInputCheckBox>(); checkbox.MouseClick(); SelectFirstSearchResult(lableName); } } } } } }
public void TestMethod_Search() { ReadData(); //Login to the system myManager.ActiveBrowser.NavigateTo(_Url); CommonFunctions.HandleSpashScreen(myManager, myManager.ActiveBrowser); myManager.ActiveBrowser.WaitUntilReady(); myManager.ActiveBrowser.RefreshDomTree(); CommonFunctions.Login(myManager, myManager.ActiveBrowser, _Uname, _Password); Thread.Sleep(7000); myManager.ActiveBrowser.WaitUntilReady(); myManager.ActiveBrowser.RefreshDomTree(); //Search using search text ObjSearch search = new ObjSearch(myManager); myManager.ActiveBrowser.Actions.Click(search.Searchicon); HtmlInputText searchtext = search.Searchtextbox.As <HtmlInputText>(); searchtext.Text = _SearchString; myManager.ActiveBrowser.Actions.Click(search.Searchbutton); Thread.Sleep(5000); myManager.ActiveBrowser.WaitUntilReady(); myManager.ActiveBrowser.RefreshDomTree(); SearchVerification(); }
void StartPageControl_KeyDown(object sender, KeyEventArgs e) { if (Key.F == e.Key && KeyboardTools.IsCTRLDown()) { ObjSearch.FocusSearchArea(); e.Handled = true; } }
public void SelectFirstSearchResult(string type) { string FirstSearchLink; Thread.Sleep(2000); myManager.ActiveBrowser.WaitUntilReady(); myManager.ActiveBrowser.RefreshDomTree(); ObjSearch search = new ObjSearch(myManager); HtmlUnorderedList SearchResult = search.ResultGri.As <HtmlUnorderedList>(); HtmlListItem firstsearchResult = SearchResult.Items[0]; HtmlAnchor firstsearchResultlink = firstsearchResult.Find.AllByTagName("a")[0].As <HtmlAnchor>(); FirstSearchLink = firstsearchResultlink.InnerText; foreach (HtmlListItem ResultlistItem in SearchResult.Items) { HtmlDiv Lidiv = ResultlistItem.Find.AllByTagName("div")[0].As <HtmlDiv>(); string classAttribute = Lidiv.Attributes[0].Value; Assert.AreEqual(classAttribute.ToLower(), type.ToLower(), "clicked on " + type + " but displays" + classAttribute); } if (FirstSearchLink.ToUpper().Contains(_SearchString.ToUpper())) { if (type != "Training") // if the browser opens training it opnes PDFs { firstsearchResultlink.MouseClick(); myManager.ActiveBrowser.WaitUntilReady(); myManager.ActiveBrowser.RefreshDomTree(); Thread.Sleep(5000); Assert.IsTrue(myManager.ActiveBrowser.ContainsText(_SearchString)); } } myManager.ActiveBrowser.WaitUntilReady(); myManager.ActiveBrowser.RefreshDomTree(); myManager.ActiveBrowser.GoBack(); Thread.Sleep(5000); myManager.ActiveBrowser.Actions.Click(search.AllSourcebutton); Thread.Sleep(2000); }