diff --git a/sources/EncodingChecker.GuiSmoke/EcGuiDriver.cs b/sources/EncodingChecker.GuiSmoke/EcGuiDriver.cs index 6e573a6..7da5732 100644 --- a/sources/EncodingChecker.GuiSmoke/EcGuiDriver.cs +++ b/sources/EncodingChecker.GuiSmoke/EcGuiDriver.cs @@ -696,9 +696,30 @@ private static string Safely(Func describe, string whenItFails) } } - private AutomationElement? FindReviewWindow() => - FindProcessElementById("ConversionConfirmationForm") ?? - FindProcessElementByTitle("Review conversion"); + /// The conversion review, if EC currently has one open. + /// + /// The review is an immediate child of the main window, so it is looked for there. + /// Searching the desktop instead means repeatedly walking unrelated applications, on + /// every poll of several waits. + /// + /// Automation errors are deliberately not caught: returning null for one would say + /// the review is absent when the truth is that nothing could be read, and the waits + /// that call this already retry and keep the error. + /// + private AutomationElement? FindReviewWindow() + { + var condition = new AndCondition( + new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window), + new OrCondition( + new PropertyCondition( + AutomationElement.AutomationIdProperty, + "ConversionConfirmationForm"), + new PropertyCondition( + AutomationElement.NameProperty, + "Review conversion"))); + + return MainWindow.FindFirst(TreeScope.Children, condition); + } private int ResultCount() => FindById(MainWindow, "lstResults") is AutomationElement list @@ -893,36 +914,6 @@ private AutomationElement RequireById( return AutomationElement.RootElement.FindFirst(TreeScope.Children, condition); } - private AutomationElement? FindProcessElementById(string automationId) - { - var condition = new AndCondition( - new PropertyCondition( - AutomationElement.ProcessIdProperty, - _process.Id), - new PropertyCondition( - AutomationElement.AutomationIdProperty, - automationId)); - - return AutomationElement.RootElement.FindFirst( - TreeScope.Descendants, - condition); - } - - private AutomationElement? FindProcessElementByTitle(string title) - { - var condition = new AndCondition( - new PropertyCondition( - AutomationElement.ProcessIdProperty, - _process.Id), - new PropertyCondition( - AutomationElement.NameProperty, - title)); - - return AutomationElement.RootElement.FindFirst( - TreeScope.Descendants, - condition); - } - private AutomationElement? FindProcessWindowByTitle(string title) { var condition = new AndCondition(