1
- using FlaUI . Core . Capturing ;
1
+ using FlaUI . Core . AutomationElements ;
2
+ using FlaUI . Core . Capturing ;
2
3
using FlaUI . Core . Definitions ;
4
+ using FlaUI . Core . Tools ;
5
+ using UITest . SystemViews ;
3
6
using Xunit ;
4
7
using Xunit . Abstractions ;
5
8
@@ -21,10 +24,30 @@ public void CreateReportTest() => Run(() =>
21
24
reportView . CreateBookListReportButton . Click ( ) ;
22
25
Assert . True ( reportView . PrintButton . IsEnabled ) ;
23
26
Capture . Screen ( ) . ToFile ( GetScreenshotFile ( "BookListReport" ) ) ;
27
+ PrintAsPdf ( GetScreenshotFile ( "BookListReport.pdf" ) ) ;
24
28
25
29
reportView . CreateBorrowedBooksReportButton . Click ( ) ;
26
30
Capture . Screen ( ) . ToFile ( GetScreenshotFile ( "BorrowedBooksReport" ) ) ;
31
+ PrintAsPdf ( GetScreenshotFile ( "BorrowedBooksReport.pdf" ) ) ;
27
32
28
- window . Close ( ) ;
33
+ var dataMenu = window . DataMenu ;
34
+ dataMenu . Click ( ) ;
35
+ dataMenu . ExitMenuItem . Click ( ) ;
36
+
37
+
38
+ void PrintAsPdf ( string fileName )
39
+ {
40
+ if ( File . Exists ( fileName ) ) File . Delete ( fileName ) ;
41
+
42
+ reportView . PrintButton . Click ( ) ;
43
+ var printDialog = PrintDialog . GetDialog ( Automation ) ;
44
+ printDialog . PrinterSelector . Select ( printDialog . PrintToPdf . Name ) ;
45
+ Retry . WhileFalse ( ( ) => printDialog . PrintButton . IsEnabled , throwOnTimeout : true ) ;
46
+ printDialog . PrintButton . Invoke ( ) ;
47
+
48
+ var saveFileDialog = window . FirstModalWindow ( ) . As < SaveFileDialog > ( ) ;
49
+ saveFileDialog . SetFileName ( fileName ) ;
50
+ saveFileDialog . SaveButton . Click ( ) ;
51
+ }
29
52
} ) ;
30
53
}
0 commit comments