Skip to content

Commit 81d713c

Browse files
committed
Merge branch 'master' into BuildWin2025
2 parents a48f560 + fe53c25 commit 81d713c

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

.github/workflows/NewsReader.CI.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ jobs:
6363
dotnet publish -f:net9.0-windows10.0.19041.0 -c:Release -p:ApplicationDisplayVersion=${{ needs.GetVersion.outputs.version }} -p:ApplicationVersion=0
6464
6565
iOS:
66-
runs-on: macos-14
66+
runs-on: macos-15
6767
needs: GetVersion
6868
steps:
6969
- name: 🔖 Check-out
7070
uses: actions/checkout@v4
7171

7272
- name: ⚙️ Set Xcode version
7373
run: |
74-
XCODE_ROOT=/Applications/Xcode_16.1.app
74+
XCODE_ROOT=/Applications/Xcode_16.2.app
7575
echo "MD_APPLE_SDK_ROOT=$XCODE_ROOT" >> $GITHUB_ENV # set environment variable to specify Xcode for Mono and Xamarin
7676
sudo xcode-select -s $XCODE_ROOT
7777

src/Samples.UITest/BookLibrary.Test/Tests/ReportingTest.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,19 @@ void PrintAsPdf(string fileName)
4242

4343
reportView.PrintButton.Click();
4444
var version = new Version(10, 0, 22621, 0); // Windows 11 22H2
45+
bool printCompleted = false;
4546
if (Environment.OSVersion.Version >= version)
4647
{
47-
var printDialog = PrintDialog.GetDialog(Automation);
48-
printDialog.PrinterSelector.Select(printDialog.PrintToPdf.Name);
49-
Retry.WhileFalse(() => printDialog.PrintButton.IsEnabled, throwOnTimeout: true);
50-
printDialog.PrintButton.Click();
48+
var printDialog = PrintDialog.TryGetDialog(Automation);
49+
if (printDialog is not null) // Windows 2025 Server uses legacy print dialog
50+
{
51+
printDialog.PrinterSelector.Select(printDialog.PrintToPdf.Name);
52+
Retry.WhileFalse(() => printDialog.PrintButton.IsEnabled, throwOnTimeout: true);
53+
printDialog.PrintButton.Invoke();
54+
printCompleted = true;
55+
}
5156
}
52-
else
57+
if (!printCompleted)
5358
{
5459
var printDialog = window.FirstModalWindow().As<LegacyPrintDialog>();
5560
Log.WriteLine("Printers:");

src/Samples.UITest/UITest.Core/SystemViews/PrintDialog.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
using FlaUI.Core;
22
using FlaUI.Core.AutomationElements;
3-
using FlaUI.Core.Conditions;
43
using FlaUI.Core.Definitions;
4+
using System.Diagnostics;
55

66
namespace UITest.SystemViews;
77

88
public class PrintDialog(FrameworkAutomationElementBase element) : Window(element)
99
{
10-
public static PrintDialog GetDialog(AutomationBase automation)
10+
public static PrintDialog? TryGetDialog(AutomationBase automation)
1111
{
12+
var p = Process.GetProcesses().FirstOrDefault(x => x.ProcessName.Contains("PrintDialog", StringComparison.OrdinalIgnoreCase));
13+
if (p is null) return null;
1214
var desktop = automation.GetDesktop();
13-
return desktop.Find(x => new AndCondition(x.ByControlType(ControlType.Window), x.ByName("Windows Print"))).As<PrintDialog>();
15+
var topLevel = desktop.FindAllChildren(x => x.ByControlType(ControlType.Window));
16+
AutomationElement? printDialog = null;
17+
foreach (var x in topLevel)
18+
{
19+
printDialog = x.FindFirstChild(x => x.ByProcessId(p.Id)); // It is a Window on the second level with process name "PrintDialog"
20+
if (printDialog is not null) break;
21+
}
22+
return printDialog?.As<PrintDialog>();
1423
}
1524

1625
public ComboBox PrinterSelector => this.Find("printerSelector").AsComboBox();

src/Samples.UITest/Writer.Test/Tests/WriterTest.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,19 @@ void PrintAsPdf(string fileName)
142142

143143
printPreviewTab.PrintButton.Click();
144144
var version = new Version(10, 0, 22621, 0); // Windows 11 22H2
145+
bool printCompleted = false;
145146
if (Environment.OSVersion.Version >= version)
146147
{
147-
var printDialog = PrintDialog.GetDialog(Automation);
148-
printDialog.PrinterSelector.Select(printDialog.PrintToPdf.Name);
149-
Retry.WhileFalse(() => printDialog.PrintButton.IsEnabled, throwOnTimeout: true);
150-
printDialog.PrintButton.Click();
148+
var printDialog = PrintDialog.TryGetDialog(Automation);
149+
if (printDialog is not null) // Windows 2025 Server uses legacy print dialog
150+
{
151+
printDialog.PrinterSelector.Select(printDialog.PrintToPdf.Name);
152+
Retry.WhileFalse(() => printDialog.PrintButton.IsEnabled, throwOnTimeout: true);
153+
printDialog.PrintButton.Invoke();
154+
printCompleted = true;
155+
}
151156
}
152-
else
157+
if (!printCompleted)
153158
{
154159
var printDialog = window.FirstModalWindow().As<LegacyPrintDialog>();
155160
printDialog.PrinterList.Select(printDialog.PrintToPdf.Text);

0 commit comments

Comments
 (0)