Added zone count test and "WaitElementBy..." methods (#1645)

This commit is contained in:
Yevhenii Holovachov
2020-03-20 12:47:57 +02:00
committed by GitHub
parent 35054c1f59
commit dee6dc1e6c
3 changed files with 253 additions and 110 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -87,7 +88,7 @@ namespace PowerToysTests
}
}
public static void WaitSeconds(int seconds)
public static void WaitSeconds(double seconds)
{
Thread.Sleep(TimeSpan.FromSeconds(seconds));
}
@@ -95,6 +96,50 @@ namespace PowerToysTests
public static void ShortWait()
{
Thread.Sleep(TimeSpan.FromSeconds(0.5));
}
//Trying to find element by XPath
protected WindowsElement WaitElementByXPath(string xPath, double maxTime = 10)
{
WindowsElement result = null;
Stopwatch timer = new Stopwatch();
timer.Start();
while (timer.Elapsed < TimeSpan.FromSeconds(maxTime))
{
try
{
result = session.FindElementByXPath(xPath);
}
catch { }
if (result != null)
{
return result;
}
}
Assert.IsNotNull(result);
return null;
}
//Trying to find element by AccessibilityId
protected WindowsElement WaitElementByAccessibilityId(string accessibilityId, double maxTime = 10)
{
WindowsElement result = null;
Stopwatch timer = new Stopwatch();
timer.Start();
while (timer.Elapsed < TimeSpan.FromSeconds(maxTime))
{
try
{
result = session.FindElementByAccessibilityId(accessibilityId);
}
catch { }
if (result != null)
{
return result;
}
}
Assert.IsNotNull(result);
return null;
}
public static void OpenSettings()