public void FindAllByxx() { // // The Find.AllByxx methods allow you to find multiple elements on the page using certain criteria // // Example 1: Get all table elements on the page. // IList <Element> tables = Find.AllByTagName("table"); Assert.IsTrue(tables.Count == 2); // Example 2: Get all table cells that contain a 'yes' // IList <Element> cells = Find.AllByContent("yes"); Assert.IsTrue(cells.Count == 5); // Example 3: Find all table rows that contain a scope=row attribute IList <Element> rows = Find.AllByAttributes("scope=row"); // partial compare (~) is also supported Assert.IsTrue(rows.Count == 3); // Example 4: Same as #1 above but using an XPath tables = Find.AllByXPath("/descendant::table"); Assert.IsTrue(tables.Count == 2); }
public void FindElementsByID() { Manager.LaunchNewBrowser(); ActiveBrowser.NavigateTo(Path.Combine(TestContext.TestDeploymentDir, TESTPAGE)); // Set the short-cuts to the main automation objects. Browser brwser = Manager.ActiveBrowser; Find rootFind = brwser.Find; // All the testregion are initialized here. TestRegion r1 = brwser.Regions["Region1"]; TestRegion r11 = brwser.Regions["Region11"]; TestRegion r111 = brwser.Regions["Region111"]; TestRegion r1111 = brwser.Regions["Region1111"]; TestRegion r112 = brwser.Regions["Region112"]; //*** Using identification by id. Element div0 = r1.Find.ById("div0"); //*** Using tag name occurrence index. Element div = r1.Find.ByTagIndex("div", 0); Element div1 = r112.Find.ByTagIndex("div", 0); // Some verification to illustrate how the same element that was found // using TestRegion Find objects above, can be also found // using the main Browser Find object. Assert.IsTrue(div.Equals(rootFind.ByTagIndex("div", 0))); Assert.IsTrue(div0.Equals(rootFind.ByTagIndex("div", 1))); //*** Using attribute identification. Assert.IsTrue(div1.Equals(rootFind.ByAttributes("id=div1"))); Assert.IsNull(rootFind.ByAttributes("id=bla")); Assert.IsNotNull(rootFind.ByAttributes("href=http://www.kayak.com")); //*** Using partial attribute identification. Assert.IsTrue(rootFind.ByAttributes("bla=~__").Equals(rootFind.ById("div7"))); Assert.IsNull(rootFind.ByAttributes("id=~div7", "bla=~wow")); Assert.IsNotNull(rootFind.ByAttributes("onclick=~clicked();", "id=~button2")); //*** Using 'All' elements identification. // Note here that the first 'div' does not have any id that contains 'div' hence the '- 1'. Assert.AreEqual(rootFind.AllByTagName("div").Count - 1, rootFind.AllByXPath("/descendant::node()[starts-with(@id,'div')]").Count); Assert.AreEqual(5, rootFind.AllByAttributes("href=http://www.kayak.com").Count); Assert.AreEqual(2, rootFind.AllByAttributes("id=~button").Count); Assert.AreEqual(10, r1.Find.AllByTagName("div").Count); Assert.AreEqual(0, r1111.Find.AllByTagName("div").Count); Assert.AreEqual(2, r111.Find.AllByTagName("a").Count); Assert.AreEqual(9, r11.Find.AllByAttributes("id=~div").Count); //*** Using NodeIndexPath identification. Assert.IsTrue(r1.Find.ByNodeIndexPath("0/1/1").IdAttributeValue.Equals("input1")); Assert.IsTrue(rootFind.ByNodeIndexPath("1/0/0").TagName.Equals("div", StringComparison.OrdinalIgnoreCase)); //*** Using name Assert.IsNull(r1.Find.ByName("bla")); }
public void AssociateToUsOffice_CodedStep() { IList <Element> secondaryofcs = Find.AllByXPath("//select[@class='listBox']/option"); int ecount = secondaryofcs.Count(); /* if(ecount > 0 ) * { * // Unselect all in SelectedSecondaryOfficeIdsSelect * // Pages.EditUser.SelectedSecondaryOfficeIdsSelect.MultiSelectByIndex(new int[0]); * // Invoke jQuery 'select' event' * //ArtOfTest.WebAii.jQuery.jQueryControl jQueryControl = Pages.EditUser.SelectedSecondaryOfficeIdsSelect.AsjQueryControl(); * //jQueryControl.InvokejQueryEvent(ArtOfTest.WebAii.jQuery.jQueryControl.jQueryControlEvents.change); * }*/ }
public void AssociateToUsOffice_CodedStep1() { // Unselect all in SelectedSecondaryOfficeIdsSelect IList <Element> secondaryofcs = Find.AllByXPath("//select[@class='listBox']/option"); int ecount = secondaryofcs.Count(); //Console.WriteLine(ecount); //Console.ReadLine(); if (ecount > 0) { Pages.EditUser0.SelectedSecondaryOfficeIdsSelect.MultiSelectByIndex(new int[0]); // Invoke jQuery 'select' event' ArtOfTest.WebAii.jQuery.jQueryControl jQueryControl = Pages.EditUser0.SelectedSecondaryOfficeIdsSelect.AsjQueryControl(); jQueryControl.InvokejQueryEvent(ArtOfTest.WebAii.jQuery.jQueryControl.jQueryControlEvents.change); } }
public void Associate_toUSOffice_CodedStep() { IList <Element> secondaryofcs = Find.AllByXPath("//select[@class='listBox']/option"); int ecount = secondaryofcs.Count(); //Console.WriteLine(ecount); //Console.ReadLine(); //if(ecount > 0 ) ActiveBrowser.ContentWindow.SetFocus(); Pages.EditUser.SelectedSecondaryOfficeIdsSelect.ScrollToVisible(); Pages.EditUser.SelectedSecondaryOfficeIdsSelect.Focus(); ActiveBrowser.Manager.Desktop.KeyBoard.KeyPress(ArtOfTest.WebAii.Win32.KeyBoard.KeysFromString("Shift+Down"), 100, ecount); ActiveBrowser.WaitUntilReady(); Pages.EditUser.BtnLeftButton.Click(); //Pages.EditUser.BtnLeftButton.Click(); }
public void VerifySortingOnInitializeWithTable() { Manager.LaunchNewBrowser(); // From http://www.telerik.com/support/demos click "Launch Kendo UI demos" ActiveBrowser.NavigateTo("http://www.telerik.com/support/demos"); ActiveBrowser.WaitUntilReady(); Find.ByXPath <HtmlAnchor>("//*[@href='http://demos.telerik.com/kendo-ui']").Click(); ActiveBrowser.WaitUntilReady(); // Verify you are on http://demos.telerik.com/kendo-ui/ Assert.AreEqual(ActiveBrowser.Url, "http://demos.telerik.com/kendo-ui/", "KendoUI Link points to the wrong page"); // Navigate to Grid -> Initialization from table demo Find.ByXPath <HtmlAnchor>("//*[@href='/kendo-ui/grid/index']").Click(); ActiveBrowser.WaitUntilReady(); Find.ByXPath <HtmlAnchor>("//*[@href='/kendo-ui/grid/from-table']").Click(); ActiveBrowser.WaitUntilReady(); // Verify Grid is loaded and has X columns and Y rows HtmlTable grid = new HtmlTable(); bool hasGridBeenLoaded; try { grid = Find.ById <HtmlTable>("grid"); hasGridBeenLoaded = true; } catch { hasGridBeenLoaded = false; } Assert.IsTrue(hasGridBeenLoaded); var gridRowsCount = grid.Find.AllByTagName <HtmlTableRow>("tr").Count(); int gridColumsCount = Find.AllByXPath("//th").Count(); Assert.AreEqual(21, gridRowsCount); Assert.AreEqual(5, gridColumsCount); // Test sorting (grid is sorded via column headers). You define what and how to test. Find.ByAttributes <HtmlControl>("data-field=year").Find.AllByTagName <HtmlAnchor>("a").FirstOrDefault().Click(); List <string> expectedSortedValues = new List <string>(); List <string> actualSortedValues = new List <string>(); ActiveBrowser.RefreshDomTree(); var gridRows = Find.AllByXPath <HtmlTableRow>("//tbody/tr"); foreach (var gridRow in gridRows) { string yearCellValue = gridRow.Find.AllByTagName <HtmlTableCell>("td")[2].InnerText; expectedSortedValues.Add(yearCellValue); actualSortedValues.Add(yearCellValue); } expectedSortedValues.Sort(); for (int i = 0; i < expectedSortedValues.Count(); i++) { Assert.AreEqual(expectedSortedValues[i], actualSortedValues[i]); } }