public void Init() { ElementScope table = scope.FindXPath(locators[0]); // body var tbody = table.FindXPath(".//tbody"); RowsOfElements = new List <List <ElementScope> >(); foreach (var tr in tbody.FindAllXPath(".//tr")) { var row = new List <ElementScope>(); RowsOfElements.Add(row); foreach (var td in tr.FindAllXPath(".//td")) { row.Add(td); } } // head if (isHeader) { ElementScope theader; IEnumerable <ElementScope> headerLines; try { theader = table.FindAllXPath(".//thead").First(); headerLines = (IEnumerable <ElementScope>)theader.FindAllXPath(".//tr"); } catch (NoSuchElementException) { theader = table; headerLines = new ElementScope[] { theader.FindAllXPath(".//tr").First() }; RowsOfElements.RemoveAt(0); } Header = new List <ElementScope>(); HeaderCaptions = new List <string>(); foreach (var tr in headerLines) { var cells = tr.FindAllXPath(".//th"); if (cells.Count() > 0) { if (Header.Count > 0) { throw new Exception( $"Too many headers in the table {locators[0]}. Contents: {theader.Text}"); } foreach (var td in cells) { Header.Add(td); HeaderCaptions.Add(td.Text); } } } } }
public static void CheckListElementExist(this ElementScope dropdown, string option, Options coypuOptions = null) // метод проверяет существует ли в списке город { if (coypuOptions == null) { coypuOptions = new Options() { TextPrecision = TextPrecision.Exact, ConsiderInvisibleElements = false } } ; //var optionToSelect = dropdown.FindXPath($".//li[.='{option}']"); Thread.Sleep(900); //var optionsToSelect = dropdown.FindAllXPath($".//li[contains(.,'{option}')]"); var optionsToSelect = dropdown.FindXPath($"//li[.='{option}']"); optionsToSelect.Hover(); Thread.Sleep(200); optionsToSelect.Click(coypuOptions); }