From 5b1de4bb58a9e77a928ea6fb6097df201693cfa9 Mon Sep 17 00:00:00 2001 From: jbe2277 Date: Sat, 2 Nov 2024 15:36:40 +0100 Subject: [PATCH 1/2] UITest/BookLib: try to get screenshot of report working --- src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs | 4 ++-- src/Samples.UITest/UITest.Core/SystemViews/PrintDialog.cs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs b/src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs index 6fb49664..cbda98d7 100644 --- a/src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs +++ b/src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs @@ -21,12 +21,12 @@ public void CreateReportTest() => Run(() => Assert.False(reportView.PrintButton.IsEnabled); // No report available - reportView.CreateBookListReportButton.Click(); + reportView.CreateBookListReportButton.Invoke(); Assert.True(reportView.PrintButton.IsEnabled); Capture.Screen().ToFile(GetScreenshotFile("BookListReport")); PrintAsPdf(GetScreenshotFile("BookListReport.pdf")); - reportView.CreateBorrowedBooksReportButton.Click(); + reportView.CreateBorrowedBooksReportButton.Invoke(); Capture.Screen().ToFile(GetScreenshotFile("BorrowedBooksReport")); PrintAsPdf(GetScreenshotFile("BorrowedBooksReport.pdf")); diff --git a/src/Samples.UITest/UITest.Core/SystemViews/PrintDialog.cs b/src/Samples.UITest/UITest.Core/SystemViews/PrintDialog.cs index 3d7b2048..55a4c696 100644 --- a/src/Samples.UITest/UITest.Core/SystemViews/PrintDialog.cs +++ b/src/Samples.UITest/UITest.Core/SystemViews/PrintDialog.cs @@ -1,5 +1,7 @@ using FlaUI.Core; using FlaUI.Core.AutomationElements; +using FlaUI.Core.Conditions; +using FlaUI.Core.Definitions; namespace UITest.SystemViews; @@ -8,7 +10,7 @@ public class PrintDialog(FrameworkAutomationElementBase element) : Window(elemen public static PrintDialog GetDialog(AutomationBase automation) { var desktop = automation.GetDesktop(); - return desktop.Find(x => x.ByName("Windows Print")).As(); + return desktop.Find(x => new AndCondition(x.ByControlType(ControlType.Window), x.ByName("Windows Print"))).As(); } public ComboBox PrinterSelector => this.Find("printerSelector").AsComboBox(); From 33c6445cab1d0e8700ff466582b1dd7df3d1d232 Mon Sep 17 00:00:00 2001 From: jbe2277 Date: Sat, 2 Nov 2024 15:53:24 +0100 Subject: [PATCH 2/2] UITest/BookLib: wait 500ms so that report generation can finish --- src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs b/src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs index cbda98d7..52f7d855 100644 --- a/src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs +++ b/src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs @@ -21,12 +21,14 @@ public void CreateReportTest() => Run(() => Assert.False(reportView.PrintButton.IsEnabled); // No report available - reportView.CreateBookListReportButton.Invoke(); + reportView.CreateBookListReportButton.Click(); + Thread.Sleep(500); Assert.True(reportView.PrintButton.IsEnabled); Capture.Screen().ToFile(GetScreenshotFile("BookListReport")); PrintAsPdf(GetScreenshotFile("BookListReport.pdf")); - reportView.CreateBorrowedBooksReportButton.Invoke(); + reportView.CreateBorrowedBooksReportButton.Click(); + Thread.Sleep(500); Capture.Screen().ToFile(GetScreenshotFile("BorrowedBooksReport")); PrintAsPdf(GetScreenshotFile("BorrowedBooksReport.pdf"));