Skip to content

Commit 169953c

Browse files
author
Jake Ginnivan
committed
Merge pull request #127 from JakeGinnivan/XmlCommentsUpdate
Xml comments update
2 parents ee057ff + 885a996 commit 169953c

File tree

11 files changed

+120
-63
lines changed

11 files changed

+120
-63
lines changed

src/TestStack.White.UnitTests/UIItems/DateFormatTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ public class DateFormatTest
88
[Fact]
99
public void DifferentDateFormats()
1010
{
11-
Assert.Equal(DateFormat.dayMonthYear, DateFormat.Create("-", "dd-MM-yyyy"));
12-
Assert.Equal(DateFormat.dayMonthYear, DateFormat.Create("-", "d-M-yyyy"));
11+
Assert.Equal(DateFormat.DayMonthYear, DateFormat.Create("-", "dd-MM-yyyy"));
12+
Assert.Equal(DateFormat.DayMonthYear, DateFormat.Create("-", "d-M-yyyy"));
1313
}
1414
}
1515
}

src/TestStack.White/Application.cs

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ private Application(Process process)
3838
/// <summary>
3939
/// Runs the process identified by the executable and creates Application object for this executable
4040
/// </summary>
41-
/// <param name="executable">location of the executable</param>
42-
/// <returns></returns>
41+
/// <param name="executable">Path to the executable</param>
42+
/// <exception cref="ArgumentNullException">No process info passed</exception>
43+
/// <exception cref="WhiteException">White Failed to Launch or Attached to process</exception>
4344
public static Application Launch(string executable)
4445
{
4546
var processStartInfo = new ProcessStartInfo(executable);
@@ -49,8 +50,8 @@ public static Application Launch(string executable)
4950
/// <summary>
5051
/// Lauches the process and creates and Application object for it
5152
/// </summary>
52-
/// <param name="processStartInfo"></param>
53-
/// <returns></returns>
53+
/// <exception cref="ArgumentNullException">No process info passed</exception>
54+
/// <exception cref="WhiteException">White Failed to Launch or Attached to process</exception>
5455
public static Application Launch(ProcessStartInfo processStartInfo)
5556
{
5657
if (string.IsNullOrEmpty(processStartInfo.WorkingDirectory)) processStartInfo.WorkingDirectory = ".";
@@ -89,22 +90,27 @@ public static Application Launch(ProcessStartInfo processStartInfo)
8990
}
9091

9192
/// <summary>
92-
/// Creates an Application object for existing process
93+
/// Attaches White to an existing process by process id
9394
/// </summary>
94-
/// <param name="processId"></param>
95-
/// <returns></returns>
95+
/// <exception cref="WhiteException">White Failed to Attach to process</exception>
9696
public static Application Attach(int processId)
9797
{
98-
Process process = Process.GetProcessById(processId);
99-
if (process == null) throw new WhiteException("Could not find process with id: " + processId);
98+
Process process;
99+
try
100+
{
101+
process = Process.GetProcessById(processId);
102+
}
103+
catch (ArgumentException e)
104+
{
105+
throw new WhiteException("Could not find process with id: " + processId, e);
106+
}
100107
return new Application(process);
101108
}
102109

103110
/// <summary>
104-
/// Attaches with existing process
111+
/// Attaches White to an existing process
105112
/// </summary>
106-
/// <param name="process"></param>
107-
/// <returns></returns>
113+
/// <exception cref="WhiteException">White Failed to Attach to process</exception>
108114
public static Application Attach(Process process)
109115
{
110116
return new Application(process);
@@ -113,8 +119,7 @@ public static Application Attach(Process process)
113119
/// <summary>
114120
/// Attaches with existing process
115121
/// </summary>
116-
/// <param name="executable"></param>
117-
/// <returns></returns>
122+
/// <exception cref="WhiteException">White Failed to Attach to process with specified name</exception>
118123
public static Application Attach(string executable)
119124
{
120125
Process[] processes = Process.GetProcessesByName(executable);
@@ -127,6 +132,9 @@ public static Application Attach(string executable)
127132
/// </summary>
128133
/// <param name="processStartInfo"></param>
129134
/// <returns></returns>
135+
/// <exception cref="ArgumentException"></exception>
136+
/// <exception cref="ArgumentNullException"></exception>
137+
/// <exception cref="WhiteException">White Failed to Launch or Attach to process</exception>
130138
public static Application AttachOrLaunch(ProcessStartInfo processStartInfo)
131139
{
132140
string processName = ReplaceLast(processStartInfo.FileName, ".exe", string.Empty);
@@ -165,17 +173,19 @@ public virtual ApplicationSession ApplicationSession
165173
/// <param name="title">Title text of window displayed on desktop</param>
166174
/// <param name="option">Option which would be used to initialize the window.</param>
167175
/// <returns></returns>
176+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
168177
public virtual Window GetWindow(string title, InitializeOption option)
169178
{
170179
WindowSession windowSession = applicationSession.WindowSession(option);
171180
return windowFactory.CreateWindow(title, process, option, windowSession);
172181
}
173182

174183
/// <summary>
175-
/// Get visible window
184+
/// Get visible window. NoCache option is set by default
176185
/// </summary>
177186
/// <param name="title">Title text of window displayed on desktop</param>
178187
/// <returns></returns>
188+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
179189
public virtual Window GetWindow(string title)
180190
{
181191
return GetWindow(title, InitializeOption.NoCache);
@@ -187,6 +197,7 @@ public virtual Window GetWindow(string title)
187197
/// <param name="searchCriteria"></param>
188198
/// <param name="initializeOption">found window would be initialized with this option</param>
189199
/// <returns></returns>
200+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
190201
public virtual Window GetWindow(SearchCriteria searchCriteria, InitializeOption initializeOption)
191202
{
192203
WindowSession windowSession = applicationSession.WindowSession(initializeOption);
@@ -234,6 +245,7 @@ public virtual void Kill()
234245
/// All windows belonging to the application
235246
/// </summary>
236247
/// <returns></returns>
248+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
237249
public virtual List<Window> GetWindows()
238250
{
239251
return windowFactory.DesktopWindows(process, new NoApplicationSession());
@@ -289,6 +301,7 @@ public virtual void WaitWhileBusy()
289301
/// </summary>
290302
/// <param name="match"></param>
291303
/// <param name="initializeOption">option for the window which matches the condition</param>
304+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
292305
public virtual Window Find(Predicate<string> match, InitializeOption initializeOption)
293306
{
294307
WindowSession windowSession = applicationSession.WindowSession(initializeOption);

src/TestStack.White/Factory/ChildWindowFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected virtual AutomationElement WaitTillFound(Func<AutomationElement> find,
4444
return element;
4545
}
4646

47+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
4748
internal static Window Create(AutomationElement element, InitializeOption option, WindowSession windowSession)
4849
{
4950
SpecializedWindowFactory specializedWindowFactory = SpecializedWindowFactories.Find(factory => factory.DoesSpecializeInThis(element));

src/TestStack.White/Factory/WindowFactory.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,31 @@ public virtual Window SplashWindow(Process process)
6868
return new SplashWindow(element, InitializeOption.NoCache);
6969
}
7070

71+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
7172
public virtual Window CreateWindow(string title, Process process, InitializeOption option, WindowSession windowSession)
7273
{
7374
var message = string.Format("Couldn't find window with title {0} in process {1}{2}", title, process.Id, ", after waiting for 30 seconds");
7475
var element = WaitTillFound(() => Finder.FindWindow(title, process.Id), message);
7576
return Create(element, option, windowSession);
7677
}
7778

79+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
7880
public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession)
7981
{
8082
var message = string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage);
8183
var element = WaitTillFound(() => Finder.FindWindow(searchCriteria, process.Id), message);
8284
return Create(element, option, windowSession);
8385
}
8486

87+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
8588
public virtual Window FindWindow(Process process, Predicate<string> match, InitializeOption initializeOption, WindowSession windowSession)
8689
{
8790
string message = string.Format("Could not find window matching condition. ProcessName: {0}, ProcessId: {1}, MatchingConditionMethod: {2}, MatchingConditionTarget: {3}", process.ProcessName, process.Id, match.Method, match.Target);
8891
var foundElement = WaitTillFound(() => FindWindowElement(process, match), message);
8992
return Create(foundElement, initializeOption, windowSession);
9093
}
9194

95+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
9296
public virtual Window FindModalWindow(string title, Process process, InitializeOption option, AutomationElement parentWindowElement,
9397
WindowSession windowSession)
9498
{
@@ -98,6 +102,7 @@ public virtual Window FindModalWindow(string title, Process process, InitializeO
98102
return Create(modalWindowElement, option, windowSession);
99103
}
100104

105+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
101106
public virtual Window FindModalWindow(SearchCriteria searchCriteria, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession)
102107
{
103108
var windowFinder = new AutomationElementFinder(parentWindowElement);
@@ -132,6 +137,7 @@ private AutomationElement FindWindowElement(Process process, Predicate<string> m
132137
});
133138
}
134139

140+
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
135141
public virtual List<Window> DesktopWindows()
136142
{
137143
var windows = new List<Window>();

src/TestStack.White/UIItems/DateFormat.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ namespace TestStack.White.UIItems
1010
/// </summary>
1111
public class DateFormat
1212
{
13-
public static DateFormat dayMonthYear = new DateFormat(DateUnit.Day, DateUnit.Month, DateUnit.Year);
14-
public static DateFormat dayYearMonth = new DateFormat(DateUnit.Day, DateUnit.Year, DateUnit.Month);
15-
public static DateFormat monthDayYear = new DateFormat(DateUnit.Month, DateUnit.Day, DateUnit.Year);
16-
public static DateFormat monthYearDay = new DateFormat(DateUnit.Month, DateUnit.Year, DateUnit.Day);
17-
public static DateFormat yearMonthDay = new DateFormat(DateUnit.Year, DateUnit.Month, DateUnit.Day);
18-
public static DateFormat yearDayMonth = new DateFormat(DateUnit.Year, DateUnit.Day, DateUnit.Month);
13+
public static DateFormat DayMonthYear = new DateFormat(DateUnit.Day, DateUnit.Month, DateUnit.Year);
14+
public static DateFormat DayYearMonth = new DateFormat(DateUnit.Day, DateUnit.Year, DateUnit.Month);
15+
public static DateFormat MonthDayYear = new DateFormat(DateUnit.Month, DateUnit.Day, DateUnit.Year);
16+
public static DateFormat MonthYearDay = new DateFormat(DateUnit.Month, DateUnit.Year, DateUnit.Day);
17+
public static DateFormat YearMonthDay = new DateFormat(DateUnit.Year, DateUnit.Month, DateUnit.Day);
18+
public static DateFormat YearDayMonth = new DateFormat(DateUnit.Year, DateUnit.Day, DateUnit.Month);
1919

2020
private readonly List<DateUnit> dateUnits = new List<DateUnit>();
2121

@@ -49,6 +49,9 @@ public static DateFormat Create(string dateSeparator, string pattern)
4949
return dateFormat;
5050
}
5151

52+
/// <summary>
53+
/// Use ',' as separator.
54+
/// </summary>
5255
public static DateFormat Parse(string @string)
5356
{
5457
string[] parts = @string.Split(',');

src/TestStack.White/UIItems/IUIItemContainer.cs

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,58 @@ namespace TestStack.White.UIItems
44
{
55
public interface IUIItemContainer : IUIItem
66
{
7-
T Get<T>() where T : UIItem;
8-
T Get<T>(string primaryIdentification) where T : UIItem;
9-
T Get<T>(SearchCriteria searchCriteria) where T : UIItem;
107
ToolTip ToolTip { get; }
118
ToolTip GetToolTipOn(UIItem uiItem);
129
IUIItem[] GetMultiple(SearchCriteria criteria);
10+
11+
/// <summary>
12+
/// Finds UIItem which matches specified type. Useful for non managed applications where controls are not identified by AutomationId, like in
13+
/// Managed applications. In case of multiple items of this type the first one found would be returned which cannot be guaranteed to be the same
14+
/// across multiple invocations.
15+
/// </summary>
16+
/// <typeparam name="T">IUIItem type e.g. Button, TextBox</typeparam>
17+
/// <returns>First item of supplied type</returns>
18+
/// <exception cref="AutomationException">when item not found</exception>
19+
/// <exception cref="WhiteException">when any errors occured during search</exception>
20+
T Get<T>() where T : IUIItem;
21+
22+
/// <summary>
23+
/// Finds UIItem which matches specified type and identification.
24+
/// In case of multiple items of this type the first one found would be returned which cannot be guaranteed to be the same across multiple
25+
/// invocations. For managed applications this is name given to controls in the application code.
26+
/// For unmanaged applications this is text of the control or label next to it if it doesn't have well defined text.
27+
/// <!--e.g. TextBox doesn't have any predefined text of its own as it can be changed at runtime by user, hence is identified by the label next to it.
28+
/// If there is no label then Get<T> or Get<T>(SearchCriteria) method can be used.-->
29+
/// </summary>
30+
/// <typeparam name="T">IUIItem implementation</typeparam>
31+
/// <param name="primaryIdentification">For managed application this is the name provided in application code and unmanaged application this is
32+
/// the text or label next to it based identification</param>
33+
/// <returns>First item of supplied type and identification</returns>
34+
/// <exception cref="AutomationException">when item not found</exception>
35+
/// <exception cref="WhiteException">when any errors occured during search</exception>
36+
T Get<T>(string primaryIdentification) where T : IUIItem;
37+
38+
/// <summary>
39+
/// Finds UIItem which matches specified type and searchCriteria. Type supplied need not be supplied again in SearchCondition.
40+
/// <!--e.g. in Get<Button>(SearchCriteria.ByAutomationId("OK").ByControlType(typeof(Button)).Indexed(1) the ByControlType(typeof(Button)) part
41+
/// is redundant. Look at documentation of SearchCriteria for details on it.-->
42+
/// </summary>
43+
/// <code>
44+
/// </code>
45+
/// <typeparam name="T"></typeparam>
46+
/// <param name="searchCriteria">Criteria provided to search UIItem</param>
47+
/// <returns>First items matching the type and criteria</returns>
48+
/// <exception cref="AutomationException">when item not found</exception>
49+
/// <exception cref="WhiteException">when any errors occured during search</exception>
50+
T Get<T>(SearchCriteria searchCriteria) where T : IUIItem;
51+
52+
/// <summary>
53+
/// Finds UIItem which matches specified type and searchCriteria using the default BusyTimeout. Look at documentation of SearchCriteria for details on it.
54+
/// </summary>
55+
/// <param name="searchCriteria">Criteria provided to search IUIItem</param>
56+
/// <returns>First items matching the criteria</returns>
57+
/// <exception cref="AutomationException">when item not found</exception>
58+
/// <exception cref="WhiteException">when any errors occured during search</exception>
59+
IUIItem Get(SearchCriteria searchCriteria);
1360
}
1461
}

src/TestStack.White/UIItems/ListViewCells.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public ListViewCells(List<AutomationElement> collection, ActionListener actionLi
1616
this.header = header;
1717
}
1818

19+
/// <exception cref="UIActionException">when header row is not defined</exception>
1920
public virtual ListViewCell this[string columnName]
2021
{
2122
get

src/TestStack.White/UIItems/SelectionItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public virtual bool IsSelected
1919
}
2020
}
2121

22+
/// <exception cref="UIActionException"></exception>
2223
public virtual void Select()
2324
{
2425
if (!Bounds.IsEmpty) Click();

src/TestStack.White/UIItems/TextBox.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public TextBox(AutomationElement automationElement, ActionListener actionListene
1414

1515
/// <summary>
1616
/// Enters the text in the textbox. The text would be cleared first. This is not as good performing as the BulkText method.
17-
/// This does raise all keyboard events.
17+
/// This does raise all keyboard events - that means that your string will consist of letters that match the letters
18+
/// of your string but in current input language.
1819
/// </summary>
1920
public virtual string Text
2021
{
@@ -34,6 +35,7 @@ public virtual string Text
3435

3536
/// <summary>
3637
/// Sets the text in the textbox. The text would be cleared first. This is a better performing than the Text method. This doesn't raise all keyboard events.
38+
/// The string will be set exactly as it is in your code.
3739
/// </summary>
3840
public virtual string BulkText
3941
{

0 commit comments

Comments
 (0)