mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2026-02-14 12:48:33 +00:00
test(BRIDGE-136): Download Bridge
This commit is contained in:
committed by
Gordana Zafirova
parent
cf9b35163a
commit
fd709b0d08
24
tests/e2e/ui_tests/windows_os/TestsHelper/DebugTests.cs
Normal file
24
tests/e2e/ui_tests/windows_os/TestsHelper/DebugTests.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using FlaUI.Core.Capturing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProtonMailBridge.UI.Tests.TestsHelper
|
||||
{
|
||||
internal class DebugTests
|
||||
{
|
||||
public void TakeScreenshot()
|
||||
{
|
||||
string testName = TestContext.CurrentContext.Test.Name;
|
||||
string Timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
string ScreenshotName = "Screenshot_" + testName + "_" + Timestamp + ".png";
|
||||
string Query = "%CI_PROJECT_DIR%\\tests\\e2e\\ui_tests\\windows_os\\Results\\artifacts\\Screenshots\\" + ScreenshotName;
|
||||
string ScreenshotLocation = Environment.ExpandEnvironmentVariables(Query);
|
||||
var ScreenshotFile = Capture.Screen();
|
||||
ScreenshotFile.ToFile(ScreenshotLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
tests/e2e/ui_tests/windows_os/TestsHelper/RetryHelper.cs
Normal file
43
tests/e2e/ui_tests/windows_os/TestsHelper/RetryHelper.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProtonMailBridge.UI.Tests.TestsHelper
|
||||
{
|
||||
public class RetryHelper
|
||||
{
|
||||
public static void Eventually(Func<bool> condition, int retries = 10, int delaySeconds = 5)
|
||||
{
|
||||
for (int i = 0; i < retries; i++)
|
||||
{
|
||||
if (condition()) return;
|
||||
|
||||
Thread.Sleep(TimeSpan.FromSeconds(delaySeconds));
|
||||
}
|
||||
|
||||
Assert.Fail();
|
||||
}
|
||||
|
||||
public static void EventuallyAction(Action action, int retries = 20, int delaySeconds = 2)
|
||||
{
|
||||
Exception? lastException = null;
|
||||
for (int i = 0; i < retries; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
return;
|
||||
} catch (Exception e)
|
||||
{
|
||||
lastException = e;
|
||||
Thread.Sleep(TimeSpan.FromSeconds(delaySeconds));
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Eventually failed after retries", lastException);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user