Compare commits

...

2 Commits

Author SHA1 Message Date
Xiaofeng Wang (from Dev Box)
d421ea7cd9 Update retry interval 2025-06-06 11:15:08 +08:00
Xiaofeng Wang (from Dev Box)
b76b37fbff Add debug log 2025-06-06 11:05:19 +08:00

View File

@@ -138,9 +138,9 @@ namespace Microsoft.PowerToys.UITest
private WindowsDriver<WindowsElement> NewWindowsDriver(AppiumOptions info)
{
// Create driver with retry
var timeout = TimeSpan.FromMinutes(2);
var retryInterval = TimeSpan.FromSeconds(5);
TimeSpan timeout = TimeSpan.FromMinutes(2);
DateTime startTime = DateTime.Now;
int retryCount = 0;
while (true)
{
@@ -149,14 +149,22 @@ namespace Microsoft.PowerToys.UITest
var res = new WindowsDriver<WindowsElement>(new Uri(ModuleConfigData.Instance.GetWindowsApplicationDriverUrl()), info);
return res;
}
catch (Exception)
catch (Exception ex)
{
if (DateTime.Now - startTime > timeout)
{
Console.WriteLine("Timeout reached. Throwing exception.");
throw;
}
TimeSpan retryInterval = retryCount < 2
? TimeSpan.FromSeconds(5)
: TimeSpan.FromSeconds(20);
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] Exception occurred: {ex.Message}, Retrying after {retryInterval.TotalSeconds} seconds...");
Task.Delay(retryInterval).Wait();
retryCount++;
}
}
}