-
Notifications
You must be signed in to change notification settings - Fork 476
Expand file tree
/
Copy pathDescendantFinder.cs
More file actions
50 lines (41 loc) · 1.85 KB
/
DescendantFinder.cs
File metadata and controls
50 lines (41 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Castle.Core.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Automation;
using TestStack.White.Configuration;
using TestStack.White.UIItems.Finders;
namespace TestStack.White.AutomationElementSearch
{
public class DescendantFinder : IDescendantFinder
{
private readonly AutomationElement automationElement;
private readonly ILogger logger = CoreAppXmlConfiguration.Instance.LoggerFactory.Create(typeof(DescendantFinder));
public DescendantFinder(AutomationElement automationElement)
{
if (automationElement == null) throw new ArgumentNullException("automationElement");
this.automationElement = automationElement;
}
public virtual AutomationElement Descendant(AutomationSearchCondition automationSearchCondition)
{
return Descendant(automationSearchCondition.Condition);
}
public virtual AutomationElement Descendant(Condition condition)
{
return automationElement.FindFirst(TreeScope.Descendants, condition);
}
public virtual List<AutomationElement> Descendants(AutomationSearchCondition automationSearchCondition)
{
var collection = automationElement.FindAll(TreeScope.Descendants, automationSearchCondition.Condition);
//Automation elements identified in current window...
//AutomationElement[] elementsArray = new AutomationElement[collection.Count];
//collection.CopyTo(elementsArray, 0);
//foreach (AutomationElement e in elementsArray)
//{
// logger.InfoFormat("Element Automation Id: ({0})..", e.Current.AutomationId);
//}
var enumerable = collection.Cast<AutomationElement>();
return new List<AutomationElement>(enumerable);
}
}
}