private static By CalculateBy(Models.TreeElement tree, int index) { if (tree == null) { throw new ArgumentNullException(nameof(tree)); } return(By.XPath(string.IsNullOrEmpty(tree.Title) ? $"./ul/li[{index}]" : $".//li[./a[contains(.,\"{tree.Title}\")]]")); }
public Branch(SeleniumElement parent, Models.TreeElement tree, int index = 1, [CallerMemberName] string?toStringValue = null) : base(parent, CalculateBy(tree, index), toStringValue) { ChildBranches = tree.Branches.Select((x, i) => new Branch(this, x, ++i, x.ToString())).ToList(); }