diff --git a/src/TestStack.White.UnitTests/UIItems/DateFormatTest.cs b/src/TestStack.White.UnitTests/UIItems/DateFormatTest.cs index b440614b..bb6850f7 100644 --- a/src/TestStack.White.UnitTests/UIItems/DateFormatTest.cs +++ b/src/TestStack.White.UnitTests/UIItems/DateFormatTest.cs @@ -8,8 +8,8 @@ public class DateFormatTest [Fact] public void DifferentDateFormats() { - Assert.Equal(DateFormat.dayMonthYear, DateFormat.Create("-", "dd-MM-yyyy")); - Assert.Equal(DateFormat.dayMonthYear, DateFormat.Create("-", "d-M-yyyy")); + Assert.Equal(DateFormat.DayMonthYear, DateFormat.Create("-", "dd-MM-yyyy")); + Assert.Equal(DateFormat.DayMonthYear, DateFormat.Create("-", "d-M-yyyy")); } } } \ No newline at end of file diff --git a/src/TestStack.White/Application.cs b/src/TestStack.White/Application.cs index eefe533a..1969acb4 100644 --- a/src/TestStack.White/Application.cs +++ b/src/TestStack.White/Application.cs @@ -38,8 +38,9 @@ private Application(Process process) /// /// Runs the process identified by the executable and creates Application object for this executable /// - /// location of the executable - /// + /// Path to the executable + /// No process info passed + /// White Failed to Launch or Attached to process public static Application Launch(string executable) { var processStartInfo = new ProcessStartInfo(executable); @@ -49,8 +50,8 @@ public static Application Launch(string executable) /// /// Lauches the process and creates and Application object for it /// - /// - /// + /// No process info passed + /// White Failed to Launch or Attached to process public static Application Launch(ProcessStartInfo processStartInfo) { if (string.IsNullOrEmpty(processStartInfo.WorkingDirectory)) processStartInfo.WorkingDirectory = "."; @@ -89,22 +90,27 @@ public static Application Launch(ProcessStartInfo processStartInfo) } /// - /// Creates an Application object for existing process + /// Attaches White to an existing process by process id /// - /// - /// + /// White Failed to Attach to process public static Application Attach(int processId) { - Process process = Process.GetProcessById(processId); - if (process == null) throw new WhiteException("Could not find process with id: " + processId); + Process process; + try + { + process = Process.GetProcessById(processId); + } + catch (ArgumentException e) + { + throw new WhiteException("Could not find process with id: " + processId, e); + } return new Application(process); } /// - /// Attaches with existing process + /// Attaches White to an existing process /// - /// - /// + /// White Failed to Attach to process public static Application Attach(Process process) { return new Application(process); @@ -113,8 +119,7 @@ public static Application Attach(Process process) /// /// Attaches with existing process /// - /// - /// + /// White Failed to Attach to process with specified name public static Application Attach(string executable) { Process[] processes = Process.GetProcessesByName(executable); @@ -127,6 +132,9 @@ public static Application Attach(string executable) /// /// /// + /// + /// + /// White Failed to Launch or Attach to process public static Application AttachOrLaunch(ProcessStartInfo processStartInfo) { string processName = ReplaceLast(processStartInfo.FileName, ".exe", string.Empty); @@ -165,6 +173,7 @@ public virtual ApplicationSession ApplicationSession /// Title text of window displayed on desktop /// Option which would be used to initialize the window. /// + /// The application type is not supported by White public virtual Window GetWindow(string title, InitializeOption option) { WindowSession windowSession = applicationSession.WindowSession(option); @@ -172,10 +181,11 @@ public virtual Window GetWindow(string title, InitializeOption option) } /// - /// Get visible window + /// Get visible window. NoCache option is set by default /// /// Title text of window displayed on desktop /// + /// The application type is not supported by White public virtual Window GetWindow(string title) { return GetWindow(title, InitializeOption.NoCache); @@ -187,6 +197,7 @@ public virtual Window GetWindow(string title) /// /// found window would be initialized with this option /// + /// The application type is not supported by White public virtual Window GetWindow(SearchCriteria searchCriteria, InitializeOption initializeOption) { WindowSession windowSession = applicationSession.WindowSession(initializeOption); @@ -234,6 +245,7 @@ public virtual void Kill() /// All windows belonging to the application /// /// + /// The application type is not supported by White public virtual List GetWindows() { return windowFactory.DesktopWindows(process, new NoApplicationSession()); @@ -289,6 +301,7 @@ public virtual void WaitWhileBusy() /// /// /// option for the window which matches the condition + /// The application type is not supported by White public virtual Window Find(Predicate match, InitializeOption initializeOption) { WindowSession windowSession = applicationSession.WindowSession(initializeOption); diff --git a/src/TestStack.White/Factory/ChildWindowFactory.cs b/src/TestStack.White/Factory/ChildWindowFactory.cs index d17d5b58..33c08a9c 100644 --- a/src/TestStack.White/Factory/ChildWindowFactory.cs +++ b/src/TestStack.White/Factory/ChildWindowFactory.cs @@ -44,6 +44,7 @@ protected virtual AutomationElement WaitTillFound(Func find, return element; } + /// The application type is not supported by White internal static Window Create(AutomationElement element, InitializeOption option, WindowSession windowSession) { SpecializedWindowFactory specializedWindowFactory = SpecializedWindowFactories.Find(factory => factory.DoesSpecializeInThis(element)); diff --git a/src/TestStack.White/Factory/WindowFactory.cs b/src/TestStack.White/Factory/WindowFactory.cs index c0bfee0f..ef891924 100644 --- a/src/TestStack.White/Factory/WindowFactory.cs +++ b/src/TestStack.White/Factory/WindowFactory.cs @@ -68,6 +68,7 @@ public virtual Window SplashWindow(Process process) return new SplashWindow(element, InitializeOption.NoCache); } + /// The application type is not supported by White public virtual Window CreateWindow(string title, Process process, InitializeOption option, WindowSession windowSession) { var message = string.Format("Couldn't find window with title {0} in process {1}{2}", title, process.Id, ", after waiting for 30 seconds"); @@ -75,6 +76,7 @@ public virtual Window CreateWindow(string title, Process process, InitializeOpti return Create(element, option, windowSession); } + /// The application type is not supported by White public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession) { var message = string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage); @@ -82,6 +84,7 @@ public virtual Window CreateWindow(SearchCriteria searchCriteria, Process proces return Create(element, option, windowSession); } + /// The application type is not supported by White public virtual Window FindWindow(Process process, Predicate match, InitializeOption initializeOption, WindowSession windowSession) { 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); @@ -89,6 +92,7 @@ public virtual Window FindWindow(Process process, Predicate match, Initi return Create(foundElement, initializeOption, windowSession); } + /// The application type is not supported by White public virtual Window FindModalWindow(string title, Process process, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession) { @@ -98,6 +102,7 @@ public virtual Window FindModalWindow(string title, Process process, InitializeO return Create(modalWindowElement, option, windowSession); } + /// The application type is not supported by White public virtual Window FindModalWindow(SearchCriteria searchCriteria, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession) { var windowFinder = new AutomationElementFinder(parentWindowElement); @@ -132,6 +137,7 @@ private AutomationElement FindWindowElement(Process process, Predicate m }); } + /// The application type is not supported by White public virtual List DesktopWindows() { var windows = new List(); diff --git a/src/TestStack.White/UIItems/DateFormat.cs b/src/TestStack.White/UIItems/DateFormat.cs index 69716b55..8cb969be 100644 --- a/src/TestStack.White/UIItems/DateFormat.cs +++ b/src/TestStack.White/UIItems/DateFormat.cs @@ -10,12 +10,12 @@ namespace TestStack.White.UIItems /// public class DateFormat { - public static DateFormat dayMonthYear = new DateFormat(DateUnit.Day, DateUnit.Month, DateUnit.Year); - public static DateFormat dayYearMonth = new DateFormat(DateUnit.Day, DateUnit.Year, DateUnit.Month); - public static DateFormat monthDayYear = new DateFormat(DateUnit.Month, DateUnit.Day, DateUnit.Year); - public static DateFormat monthYearDay = new DateFormat(DateUnit.Month, DateUnit.Year, DateUnit.Day); - public static DateFormat yearMonthDay = new DateFormat(DateUnit.Year, DateUnit.Month, DateUnit.Day); - public static DateFormat yearDayMonth = new DateFormat(DateUnit.Year, DateUnit.Day, DateUnit.Month); + public static DateFormat DayMonthYear = new DateFormat(DateUnit.Day, DateUnit.Month, DateUnit.Year); + public static DateFormat DayYearMonth = new DateFormat(DateUnit.Day, DateUnit.Year, DateUnit.Month); + public static DateFormat MonthDayYear = new DateFormat(DateUnit.Month, DateUnit.Day, DateUnit.Year); + public static DateFormat MonthYearDay = new DateFormat(DateUnit.Month, DateUnit.Year, DateUnit.Day); + public static DateFormat YearMonthDay = new DateFormat(DateUnit.Year, DateUnit.Month, DateUnit.Day); + public static DateFormat YearDayMonth = new DateFormat(DateUnit.Year, DateUnit.Day, DateUnit.Month); private readonly List dateUnits = new List(); @@ -49,6 +49,9 @@ public static DateFormat Create(string dateSeparator, string pattern) return dateFormat; } + /// + /// Use ',' as separator. + /// public static DateFormat Parse(string @string) { string[] parts = @string.Split(','); diff --git a/src/TestStack.White/UIItems/IUIItemContainer.cs b/src/TestStack.White/UIItems/IUIItemContainer.cs index 1ecd9d99..5e9cc01b 100644 --- a/src/TestStack.White/UIItems/IUIItemContainer.cs +++ b/src/TestStack.White/UIItems/IUIItemContainer.cs @@ -4,11 +4,58 @@ namespace TestStack.White.UIItems { public interface IUIItemContainer : IUIItem { - T Get() where T : UIItem; - T Get(string primaryIdentification) where T : UIItem; - T Get(SearchCriteria searchCriteria) where T : UIItem; ToolTip ToolTip { get; } ToolTip GetToolTipOn(UIItem uiItem); IUIItem[] GetMultiple(SearchCriteria criteria); + + /// + /// Finds UIItem which matches specified type. Useful for non managed applications where controls are not identified by AutomationId, like in + /// 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 + /// across multiple invocations. + /// + /// IUIItem type e.g. Button, TextBox + /// First item of supplied type + /// when item not found + /// when any errors occured during search + T Get() where T : IUIItem; + + /// + /// Finds UIItem which matches specified type and identification. + /// 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 + /// invocations. For managed applications this is name given to controls in the application code. + /// For unmanaged applications this is text of the control or label next to it if it doesn't have well defined text. + /// + /// + /// IUIItem implementation + /// For managed application this is the name provided in application code and unmanaged application this is + /// the text or label next to it based identification + /// First item of supplied type and identification + /// when item not found + /// when any errors occured during search + T Get(string primaryIdentification) where T : IUIItem; + + /// + /// Finds UIItem which matches specified type and searchCriteria. Type supplied need not be supplied again in SearchCondition. + /// + /// + /// + /// + /// + /// Criteria provided to search UIItem + /// First items matching the type and criteria + /// when item not found + /// when any errors occured during search + T Get(SearchCriteria searchCriteria) where T : IUIItem; + + /// + /// Finds UIItem which matches specified type and searchCriteria using the default BusyTimeout. Look at documentation of SearchCriteria for details on it. + /// + /// Criteria provided to search IUIItem + /// First items matching the criteria + /// when item not found + /// when any errors occured during search + IUIItem Get(SearchCriteria searchCriteria); } } \ No newline at end of file diff --git a/src/TestStack.White/UIItems/ListViewCells.cs b/src/TestStack.White/UIItems/ListViewCells.cs index 8de7fc14..3c81ef4b 100644 --- a/src/TestStack.White/UIItems/ListViewCells.cs +++ b/src/TestStack.White/UIItems/ListViewCells.cs @@ -16,6 +16,7 @@ public ListViewCells(List collection, ActionListener actionLi this.header = header; } + /// when header row is not defined public virtual ListViewCell this[string columnName] { get diff --git a/src/TestStack.White/UIItems/SelectionItem.cs b/src/TestStack.White/UIItems/SelectionItem.cs index a01c616a..5c32e71d 100644 --- a/src/TestStack.White/UIItems/SelectionItem.cs +++ b/src/TestStack.White/UIItems/SelectionItem.cs @@ -19,6 +19,7 @@ public virtual bool IsSelected } } + /// public virtual void Select() { if (!Bounds.IsEmpty) Click(); diff --git a/src/TestStack.White/UIItems/TextBox.cs b/src/TestStack.White/UIItems/TextBox.cs index 9335a371..ffcc12d4 100644 --- a/src/TestStack.White/UIItems/TextBox.cs +++ b/src/TestStack.White/UIItems/TextBox.cs @@ -14,7 +14,8 @@ public TextBox(AutomationElement automationElement, ActionListener actionListene /// /// Enters the text in the textbox. The text would be cleared first. This is not as good performing as the BulkText method. - /// This does raise all keyboard events. + /// This does raise all keyboard events - that means that your string will consist of letters that match the letters + /// of your string but in current input language. /// public virtual string Text { @@ -34,6 +35,7 @@ public virtual string Text /// /// 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. + /// The string will be set exactly as it is in your code. /// public virtual string BulkText { diff --git a/src/TestStack.White/UIItems/UIItemContainer.cs b/src/TestStack.White/UIItems/UIItemContainer.cs index 1581ff58..11239d8e 100644 --- a/src/TestStack.White/UIItems/UIItemContainer.cs +++ b/src/TestStack.White/UIItems/UIItemContainer.cs @@ -45,53 +45,21 @@ public UIItemContainer(AutomationElement automationElement, ActionListener actio { } - /// - /// Finds UIItem which matches specified type. Useful for non managed applications where controls are not identified by AutomationId, like in - /// 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 - /// across multiple invocations. - /// - /// UIItem type e.g. Button, TextBox - /// First item of supplied type - public virtual T Get() where T : UIItem + public virtual T Get() where T : IUIItem { return Get(SearchCriteria.All); } - /// - /// Finds UIItem which matches specified type and identification. - /// 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 - /// invocations. For managed applications this is name given to controls in the application code. - /// For unmanaged applications this is text of the control or label next to it if it doesn't have well defined text. - /// 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. - /// If there is no label then Get or Get(SearchCriteria) method can be used. - /// - /// UIItem type - /// For managed application this is the name provided in application code and unmanaged application this is - /// the text or label next to it based identification - /// First item of supplied type and identification - public virtual T Get(string primaryIdentification) where T : UIItem + public virtual T Get(string primaryIdentification) where T : IUIItem { return Get(SearchCriteria.ByAutomationId(primaryIdentification)); } - /// - /// Finds UIItem which matches specified type and searchCriteria. Type supplied need not be supplied again in SearchCondition. - /// e.g. in Get - /// - /// Criteria provided to search UIItem - /// First items matching the type and criteria - public virtual T Get(SearchCriteria searchCriteria) where T : UIItem + public virtual T Get(SearchCriteria searchCriteria) where T : IUIItem { return (T) Get(searchCriteria.AndControlType(typeof (T), Framework)); } - /// - /// Finds UIItem which matches specified type and searchCriteria using the default BusyTimeout. Look at documentation of SearchCriteria for details on it. - /// - /// Criteria provided to search UIItem - /// First items matching the criteria public virtual IUIItem Get(SearchCriteria searchCriteria) { return Get(searchCriteria, CoreAppXmlConfiguration.Instance.BusyTimeout()); @@ -100,9 +68,11 @@ public virtual IUIItem Get(SearchCriteria searchCriteria) /// /// Finds UIItem which matches specified type and searchCriteria. Look at documentation of SearchCriteria for details on it. /// - /// Criteria provided to search UIItem + /// Criteria provided to search IUIItem /// Time to wait for item to come on-screen before returning off-screen element, if found. /// First items matching the criteria + /// when item not found + /// when any errors occured during search public virtual IUIItem Get(SearchCriteria searchCriteria, TimeSpan timeout) { try diff --git a/src/TestStack.White/UIItems/WindowItems/Window.cs b/src/TestStack.White/UIItems/WindowItems/Window.cs index 42a846cd..b546fc59 100644 --- a/src/TestStack.White/UIItems/WindowItems/Window.cs +++ b/src/TestStack.White/UIItems/WindowItems/Window.cs @@ -93,6 +93,10 @@ private WindowPattern WinPattern get { return (WindowPattern)Pattern(WindowPattern.Pattern); } } + /// + /// Returns true if window available and is on screen. Otherwise + /// or if there were errors it returns false. + /// public virtual bool IsClosed { get @@ -211,6 +215,8 @@ protected static void HourGlassWait() } } + /// + /// when window is not responding private void WaitForWindow() { var windowPattern = (WindowPattern)Pattern(WindowPattern.Pattern); @@ -237,6 +243,7 @@ private bool IsConsole() return ("ConsoleWindowClass".Equals(automationElement.Current.ClassName)); } + /// when current process is not available any more (id expired) protected virtual void WaitForProcess() { Process.GetProcessById(automationElement.Current.ProcessId).WaitForInputIdle(); @@ -290,11 +297,16 @@ public override void Visit(WindowControlVisitor windowControlVisitor) CurrentContainerItemFactory.Visit(windowControlVisitor); } + /// + /// Execute WaitTill with the default timeout from CoreConfiguration (BusyTimeout) + /// + /// when methods reached the timeout public virtual void WaitTill(WaitTillDelegate waitTillDelegate) { WaitTill(waitTillDelegate, CoreAppXmlConfiguration.Instance.BusyTimeout()); } + /// when methods reached the timeout public virtual void WaitTill(WaitTillDelegate waitTillDelegate, TimeSpan timeout) { if (!Retry.For(() => waitTillDelegate(), timeout, new TimeSpan?())) @@ -412,6 +424,7 @@ public override VerticalSpan VerticalSpan /// Recursively gets all the descendant windows. /// /// + /// The application type is not supported by White // from ChildWindowFactory.Create public virtual List ModalWindows() { var finder = new AutomationElementFinder(automationElement);