Skip to content

Commit 8ace97c

Browse files
committed
Fixing tabs.
1 parent 5e2eab9 commit 8ace97c

File tree

1 file changed

+103
-103
lines changed

1 file changed

+103
-103
lines changed

UITests/SessionManager.cs

+103-103
Original file line numberDiff line numberDiff line change
@@ -24,129 +24,129 @@
2424

2525
namespace UITests
2626
{
27-
[TestClass]
28-
public class SessionManager
29-
{
30-
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
31-
private static readonly string[] WinUIGalleryAppIDs = new string[]{
32-
// WinUI 3 Gallery apps built in the lab
27+
[TestClass]
28+
public class SessionManager
29+
{
30+
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
31+
private static readonly string[] WinUIGalleryAppIDs = new string[]{
32+
// WinUI 3 Gallery apps built in the lab
3333
"Microsoft.WinUI3ControlsGallery.Debug_grv3cx5qrw0gp!App",
3434
"Microsoft.WinUI3ControlsGallery_grv3cx5qrw0gp!App",
35-
// WinUI 3 Gallery apps built locally
35+
// WinUI 3 Gallery apps built locally
3636
"Microsoft.WinUI3ControlsGallery.Debug_8wekyb3d8bbwe!App",
3737
"Microsoft.WinUI3ControlsGallery_8wekyb3d8bbwe!App"
3838
};
3939

40-
private static uint appIdIndex = 0;
40+
private static uint appIdIndex = 0;
4141

42-
private static WindowsDriver<WindowsElement> _session;
43-
public static WindowsDriver<WindowsElement> Session
44-
{
45-
get
46-
{
47-
if (_session is null)
48-
{
49-
Setup(null);
50-
}
51-
return _session;
52-
}
53-
}
42+
private static WindowsDriver<WindowsElement> _session;
43+
public static WindowsDriver<WindowsElement> Session
44+
{
45+
get
46+
{
47+
if (_session is null)
48+
{
49+
Setup(null);
50+
}
51+
return _session;
52+
}
53+
}
5454

55-
[AssemblyInitialize]
56-
public static void Setup(TestContext _)
57-
{
58-
if (_session is null)
59-
{
55+
[AssemblyInitialize]
56+
public static void Setup(TestContext _)
57+
{
58+
if (_session is null)
59+
{
6060

61-
int timeoutCount = 50;
61+
int timeoutCount = 50;
6262

63-
TryInitializeSession();
64-
if (_session is null)
65-
{
63+
TryInitializeSession();
64+
if (_session is null)
65+
{
6666
// WinAppDriver is probably not running, so lets start it!
6767
string winAppDriverX64Path = Path.Join(Environment.GetEnvironmentVariable("ProgramFiles"), "Windows Application Driver", "WinAppDriver.exe");
6868
string winAppDriverX86Path = Path.Join(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), "Windows Application Driver", "WinAppDriver.exe");
6969

7070
if (File.Exists(winAppDriverX64Path))
71-
{
72-
Process.Start(winAppDriverX64Path);
73-
}
74-
else if (File.Exists(winAppDriverX86Path))
75-
{
76-
Process.Start(winAppDriverX86Path);
77-
}
78-
else
79-
{
80-
throw new Exception("Unable to start WinAppDriver since no suitable location was found.");
81-
}
71+
{
72+
Process.Start(winAppDriverX64Path);
73+
}
74+
else if (File.Exists(winAppDriverX86Path))
75+
{
76+
Process.Start(winAppDriverX86Path);
77+
}
78+
else
79+
{
80+
throw new Exception("Unable to start WinAppDriver since no suitable location was found.");
81+
}
8282

83-
Thread.Sleep(10000);
84-
TryInitializeSession();
85-
}
83+
Thread.Sleep(10000);
84+
TryInitializeSession();
85+
}
8686

87-
while (_session is null && timeoutCount < 1000 * 4)
88-
{
89-
TryInitializeSession();
90-
Thread.Sleep(timeoutCount);
91-
timeoutCount *= 2;
92-
}
87+
while (_session is null && timeoutCount < 1000 * 4)
88+
{
89+
TryInitializeSession();
90+
Thread.Sleep(timeoutCount);
91+
timeoutCount *= 2;
92+
}
9393

94-
Thread.Sleep(3000);
95-
Assert.IsNotNull(_session);
96-
Assert.IsNotNull(_session.SessionId);
97-
AxeHelper.InitializeAxe();
98-
99-
// Dismiss the disclaimer window that may pop up on the very first application launch
100-
// If the disclaimer is not found, this throws an exception, so lets catch that
101-
try
102-
{
103-
_session.FindElementByName("Disclaimer").FindElementByName("Accept").Click();
104-
}
105-
catch (OpenQA.Selenium.WebDriverException) { }
94+
Thread.Sleep(3000);
95+
Assert.IsNotNull(_session);
96+
Assert.IsNotNull(_session.SessionId);
97+
AxeHelper.InitializeAxe();
98+
99+
// Dismiss the disclaimer window that may pop up on the very first application launch
100+
// If the disclaimer is not found, this throws an exception, so lets catch that
101+
try
102+
{
103+
_session.FindElementByName("Disclaimer").FindElementByName("Accept").Click();
104+
}
105+
catch (OpenQA.Selenium.WebDriverException) { }
106106

107-
// Wait if something is still animating in the visual tree
108-
_session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3);
109-
_session.Manage().Window.Maximize();
110-
}
111-
}
107+
// Wait if something is still animating in the visual tree
108+
_session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(3);
109+
_session.Manage().Window.Maximize();
110+
}
111+
}
112112

113-
[AssemblyCleanup()]
114-
public static void TestRunTearDown()
115-
{
116-
TearDown();
117-
}
113+
[AssemblyCleanup()]
114+
public static void TestRunTearDown()
115+
{
116+
TearDown();
117+
}
118118

119-
public static void TearDown()
120-
{
121-
if (_session is not null)
122-
{
123-
_session.CloseApp();
124-
_session.Quit();
125-
_session = null;
126-
}
127-
}
119+
public static void TearDown()
120+
{
121+
if (_session is not null)
122+
{
123+
_session.CloseApp();
124+
_session.Quit();
125+
_session = null;
126+
}
127+
}
128128

129-
private static void TryInitializeSession()
130-
{
131-
AppiumOptions appiumOptions = new AppiumOptions();
132-
appiumOptions.AddAdditionalCapability("app", WinUIGalleryAppIDs[appIdIndex]);
133-
appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC");
134-
try
135-
{
136-
_session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appiumOptions);
137-
}
138-
catch (OpenQA.Selenium.WebDriverException exc)
139-
{
140-
// Use next app ID since the current one was failing
141-
if (exc.Message.Contains("Package was not found"))
142-
{
143-
appIdIndex++;
144-
}
145-
else
146-
{
147-
Console.WriteLine("Failed to update start driver, got exception:" + exc.Message);
148-
}
149-
}
150-
}
151-
}
129+
private static void TryInitializeSession()
130+
{
131+
AppiumOptions appiumOptions = new AppiumOptions();
132+
appiumOptions.AddAdditionalCapability("app", WinUIGalleryAppIDs[appIdIndex]);
133+
appiumOptions.AddAdditionalCapability("deviceName", "WindowsPC");
134+
try
135+
{
136+
_session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appiumOptions);
137+
}
138+
catch (OpenQA.Selenium.WebDriverException exc)
139+
{
140+
// Use next app ID since the current one was failing
141+
if (exc.Message.Contains("Package was not found"))
142+
{
143+
appIdIndex++;
144+
}
145+
else
146+
{
147+
Console.WriteLine("Failed to update start driver, got exception:" + exc.Message);
148+
}
149+
}
150+
}
151+
}
152152
}

0 commit comments

Comments
 (0)