@@ -25,30 +25,42 @@ public SystemTests()
2525 [ Fact , Trait ( "type" , "system" ) ]
2626 public void ShouldUpdateWallpaper ( )
2727 {
28- driver . FindElementByXPath ( "//Window[@Name='Select Language']" ) . Click ( ) ;
29- driver . FindElementByXPath ( "//Button[@Name='OK']" ) . Click ( ) ;
30- Thread . Sleep ( TimeSpan . FromSeconds ( 5 ) ) ;
28+ try
29+ {
30+ driver . FindElementByXPath ( "//Window[@Name='Select Language']" ) . Click ( ) ;
31+ driver . FindElementByXPath ( "//Button[@Name='OK']" ) . Click ( ) ;
32+ Thread . Sleep ( TimeSpan . FromSeconds ( 5 ) ) ;
3133
32- if ( HandleLocationPrompt ( ) ) Thread . Sleep ( TimeSpan . FromSeconds ( 2 ) ) ;
33- driver . SwitchTo ( ) . Window ( driver . WindowHandles [ 0 ] ) ;
34- driver . FindElementByXPath ( "//Window[@Name='Configure Schedule']" ) . Click ( ) ;
35- driver . FindElementByAccessibilityId ( "radioButton1" ) . Click ( ) ;
36- driver . FindElementByAccessibilityId ( "locationBox" ) . SendKeys ( "New York NY" ) ;
37- driver . FindElementByXPath ( "//Button[@Name='OK']" ) . Click ( ) ;
38- Thread . Sleep ( TimeSpan . FromSeconds ( 2 ) ) ;
39- driver . FindElementByXPath ( "//Button[@Name='Yes']" ) . Click ( ) ;
40- Thread . Sleep ( TimeSpan . FromSeconds ( 5 ) ) ;
34+ if ( HandleLocationPrompt ( ) ) Thread . Sleep ( TimeSpan . FromSeconds ( 2 ) ) ;
35+ driver . SwitchTo ( ) . Window ( driver . WindowHandles [ 0 ] ) ;
36+ driver . FindElementByXPath ( "//Window[@Name='Configure Schedule']" ) . Click ( ) ;
37+ driver . FindElementByAccessibilityId ( "radioButton1" ) . Click ( ) ;
38+ driver . FindElementByAccessibilityId ( "locationBox" ) . SendKeys ( "New York NY" ) ;
39+ driver . FindElementByXPath ( "//Button[@Name='OK']" ) . Click ( ) ;
40+ Thread . Sleep ( TimeSpan . FromSeconds ( 2 ) ) ;
41+ driver . FindElementByXPath ( "//Button[@Name='Yes']" ) . Click ( ) ;
42+ Thread . Sleep ( TimeSpan . FromSeconds ( 5 ) ) ;
4143
42- driver . SwitchTo ( ) . Window ( driver . WindowHandles [ 0 ] ) ;
43- driver . FindElementByXPath ( "//Window[@Name='Select Theme']" ) . Click ( ) ;
44- driver . FindElementByAccessibilityId ( "listView1" ) . SendKeys ( Keys . Control + Keys . End ) ;
45- driver . FindElementByXPath ( "//ListItem[@Name='Windows 11']" ) . Click ( ) ;
46- driver . FindElementByXPath ( "//Button[@Name='Apply']" ) . Click ( ) ;
47- Thread . Sleep ( TimeSpan . FromSeconds ( 2 ) ) ;
44+ driver . SwitchTo ( ) . Window ( driver . WindowHandles [ 0 ] ) ;
45+ driver . FindElementByXPath ( "//Window[@Name='Select Theme']" ) . Click ( ) ;
46+ driver . FindElementByAccessibilityId ( "listView1" ) . SendKeys ( Keys . Control + Keys . End ) ;
47+ driver . FindElementByXPath ( "//ListItem[@Name='Windows 11']" ) . Click ( ) ;
48+ driver . FindElementByXPath ( "//Button[@Name='Apply']" ) . Click ( ) ;
49+ Thread . Sleep ( TimeSpan . FromSeconds ( 2 ) ) ;
4850
49- Assert . Contains ( [ "scripts" , "settings.json" , "themes" ] ,
51+ Assert . Contains ( [ "scripts" , "settings.json" , "themes" ] ,
5052 Directory . GetFileSystemEntries ( Path . GetDirectoryName ( AppPath ) ) . Select ( Path . GetFileName ) . ToArray ( ) ) ;
51- Assert . StartsWith ( Path . Combine ( Path . GetDirectoryName ( AppPath ) , "themes" , "Windows_11" , "img" ) , GetWallpaperPath ( ) ) ;
53+ Assert . StartsWith ( Path . Combine ( Path . GetDirectoryName ( AppPath ) , "themes" , "Windows_11" , "img" ) , GetWallpaperPath ( ) ) ;
54+ }
55+ catch ( WebDriverException )
56+ {
57+ try
58+ {
59+ driver . GetScreenshot ( ) . SaveAsFile ( Path . Combine ( Path . GetDirectoryName ( AppPath ) , "screenshot.png" ) ) ;
60+ }
61+ catch { /* Do nothing */ }
62+ throw ;
63+ }
5264 }
5365
5466 public void Dispose ( )
0 commit comments