WinAppDriver tests fix (#2006)

* updated wait methods and launch
* canvas zone resize tests updated
* updated editor opening
This commit is contained in:
Seraphima Zykova
2020-04-10 18:52:16 +03:00
committed by GitHub
parent f589dd2f26
commit 14441ec144
9 changed files with 176 additions and 208 deletions

View File

@@ -26,13 +26,18 @@ namespace PowerToysTests
Assert.IsNotNull(topBorder); Assert.IsNotNull(topBorder);
Assert.IsNotNull(bottomBorder); Assert.IsNotNull(bottomBorder);
int height = bottomBorder.Rect.Y - topBorder.Rect.Y;
//up //up
new Actions(session).MoveToElement(topBorder).ClickAndHold().MoveByOffset(0, -5000).Release().Perform(); new Actions(session).MoveToElement(topBorder).ClickAndHold().MoveByOffset(0, -5000).Release().Perform();
Assert.IsTrue(topBorder.Rect.Y >= 0); Assert.IsTrue(topBorder.Rect.Y >= 0);
Assert.IsTrue(height < bottomBorder.Rect.Y - topBorder.Rect.Y);
height = bottomBorder.Rect.Y - topBorder.Rect.Y;
//down //down
new Actions(session).MoveToElement(topBorder).ClickAndHold().MoveByOffset(0, 5000).Release().Perform(); new Actions(session).MoveToElement(topBorder).ClickAndHold().MoveByOffset(0, 5000).Release().Perform();
Assert.IsTrue(topBorder.Rect.Y <= bottomBorder.Rect.Y); Assert.IsTrue(topBorder.Rect.Y <= bottomBorder.Rect.Y);
Assert.IsTrue(height > bottomBorder.Rect.Y - topBorder.Rect.Y);
} }
[TestMethod] [TestMethod]
@@ -43,13 +48,18 @@ namespace PowerToysTests
Assert.IsNotNull(topBorder); Assert.IsNotNull(topBorder);
Assert.IsNotNull(bottomBorder); Assert.IsNotNull(bottomBorder);
int height = bottomBorder.Rect.Y - topBorder.Rect.Y;
//up //up
new Actions(session).MoveToElement(bottomBorder).ClickAndHold().MoveByOffset(0, -5000).Release().Perform(); new Actions(session).MoveToElement(bottomBorder).ClickAndHold().MoveByOffset(0, -5000).Release().Perform();
Assert.IsTrue(topBorder.Rect.Y <= bottomBorder.Rect.Y); Assert.IsTrue(topBorder.Rect.Y <= bottomBorder.Rect.Y);
Assert.IsTrue(height > bottomBorder.Rect.Y - topBorder.Rect.Y);
height = bottomBorder.Rect.Y - topBorder.Rect.Y;
//down //down
new Actions(session).MoveToElement(bottomBorder).ClickAndHold().MoveByOffset(0, 5000).Release().Perform(); new Actions(session).MoveToElement(bottomBorder).ClickAndHold().MoveByOffset(0, 5000).Release().Perform();
Assert.IsTrue(bottomBorder.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom); Assert.IsTrue(bottomBorder.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom);
Assert.IsTrue(height < bottomBorder.Rect.Y - topBorder.Rect.Y);
} }
[TestMethod] [TestMethod]
@@ -60,13 +70,18 @@ namespace PowerToysTests
Assert.IsNotNull(leftBorder); Assert.IsNotNull(leftBorder);
Assert.IsNotNull(rightBorder); Assert.IsNotNull(rightBorder);
int width = rightBorder.Rect.X - leftBorder.Rect.X;
//to the left //to the left
new Actions(session).MoveToElement(leftBorder).ClickAndHold().MoveByOffset(-5000, 0).Release().Perform(); new Actions(session).MoveToElement(leftBorder).ClickAndHold().MoveByOffset(-5000, 0).Release().Perform();
Assert.IsTrue(leftBorder.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom); Assert.IsTrue(leftBorder.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom);
Assert.IsTrue(width < rightBorder.Rect.X - leftBorder.Rect.X);
width = rightBorder.Rect.X - leftBorder.Rect.X;
//to the right //to the right
new Actions(session).MoveToElement(leftBorder).ClickAndHold().MoveByOffset(5000, 0).Release().Perform(); new Actions(session).MoveToElement(leftBorder).ClickAndHold().MoveByOffset(5000, 0).Release().Perform();
Assert.IsTrue(leftBorder.Rect.X <= rightBorder.Rect.X); Assert.IsTrue(leftBorder.Rect.X <= rightBorder.Rect.X);
Assert.IsTrue(width > rightBorder.Rect.X - leftBorder.Rect.X);
} }
[TestMethod] [TestMethod]
@@ -77,13 +92,18 @@ namespace PowerToysTests
Assert.IsNotNull(leftBorder); Assert.IsNotNull(leftBorder);
Assert.IsNotNull(rightBorder); Assert.IsNotNull(rightBorder);
int width = rightBorder.Rect.X - leftBorder.Rect.X;
//to the left //to the left
new Actions(session).MoveToElement(rightBorder).ClickAndHold().MoveByOffset(-5000, 0).Release().Perform(); new Actions(session).MoveToElement(rightBorder).ClickAndHold().MoveByOffset(-5000, 0).Release().Perform();
Assert.IsTrue(leftBorder.Rect.X <= rightBorder.Rect.X); Assert.IsTrue(leftBorder.Rect.X <= rightBorder.Rect.X);
Assert.IsTrue(width > rightBorder.Rect.X - leftBorder.Rect.X);
width = rightBorder.Rect.X - leftBorder.Rect.X;
//to the right //to the right
new Actions(session).MoveToElement(rightBorder).ClickAndHold().MoveByOffset(5000, 0).Release().Perform(); new Actions(session).MoveToElement(rightBorder).ClickAndHold().MoveByOffset(5000, 0).Release().Perform();
Assert.IsTrue(leftBorder.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right); Assert.IsTrue(leftBorder.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right);
Assert.IsTrue(width < rightBorder.Rect.X - leftBorder.Rect.X);
} }
[TestMethod] [TestMethod]
@@ -96,41 +116,32 @@ namespace PowerToysTests
Assert.IsNotNull(bottomBorder); Assert.IsNotNull(bottomBorder);
Assert.IsNotNull(rightBorder); Assert.IsNotNull(rightBorder);
//up int expectedWidth = rightBorder.Rect.X - topLeftCorner.Rect.X;
MoveCorner(topLeftCorner, true, true, 0, -5000); int expectedHeight = bottomBorder.Rect.Y - topLeftCorner.Rect.Y;
Assert.IsTrue(topLeftCorner.Rect.Y >= 0); int actualWidth, actualHeight;
//down
MoveCorner(topLeftCorner, true, true, 0, 5000);
Assert.IsTrue(topLeftCorner.Rect.Y <= bottomBorder.Rect.Y);
//up-left //up-left
MoveCorner(topLeftCorner, true, true, -5000, -5000); MoveCorner(topLeftCorner, true, true, -5000, -5000);
actualHeight = bottomBorder.Rect.Y - topLeftCorner.Rect.Y;
actualWidth = rightBorder.Rect.X - topLeftCorner.Rect.X;
Assert.IsTrue(topLeftCorner.Rect.Y >= 0); Assert.IsTrue(topLeftCorner.Rect.Y >= 0);
Assert.IsTrue(topLeftCorner.Rect.X >= 0); Assert.IsTrue(topLeftCorner.Rect.X >= 0);
Assert.IsTrue(actualHeight > expectedHeight);
Assert.IsTrue(actualWidth > expectedWidth);
//up-right expectedHeight = actualHeight;
MoveCorner(topLeftCorner, true, true, 5000, -5000); expectedWidth = actualWidth;
Assert.IsTrue(topLeftCorner.Rect.Y >= 0);
Assert.IsTrue(topLeftCorner.Rect.X <= rightBorder.Rect.X);
//to the left
MoveCorner(topLeftCorner, true, true, -5000, 0);
Assert.IsTrue(topLeftCorner.Rect.X >= 0);
//to the right
MoveCorner(topLeftCorner, true, true, 5000, 0);
Assert.IsTrue(topLeftCorner.Rect.X <= rightBorder.Rect.X);
//down-left
MoveCorner(topLeftCorner, true, true, -5000, 5000);
Assert.IsTrue(topLeftCorner.Rect.Y <= bottomBorder.Rect.Y);
Assert.IsTrue(topLeftCorner.Rect.X >= 0);
//down-right //down-right
MoveCorner(topLeftCorner, true, true, 5000, 5000); MoveCorner(topLeftCorner, true, true, 5000, 5000);
actualHeight = bottomBorder.Rect.Y - topLeftCorner.Rect.Y;
actualWidth = rightBorder.Rect.X - topLeftCorner.Rect.X;
Assert.IsTrue(topLeftCorner.Rect.Y <= bottomBorder.Rect.Y); Assert.IsTrue(topLeftCorner.Rect.Y <= bottomBorder.Rect.Y);
Assert.IsTrue(topLeftCorner.Rect.X <= rightBorder.Rect.X); Assert.IsTrue(topLeftCorner.Rect.X <= rightBorder.Rect.X);
Assert.IsTrue(actualHeight < expectedHeight);
Assert.IsTrue(actualWidth < expectedWidth);
} }
[TestMethod] [TestMethod]
@@ -143,41 +154,32 @@ namespace PowerToysTests
Assert.IsNotNull(bottomBorder); Assert.IsNotNull(bottomBorder);
Assert.IsNotNull(leftBorder); Assert.IsNotNull(leftBorder);
//up int expectedWidth = topRightCorner.Rect.X - leftBorder.Rect.X;
MoveCorner(topRightCorner, false, true, 0, -5000); int expectedHeight = bottomBorder.Rect.Y - topRightCorner.Rect.Y;
Assert.IsTrue(topRightCorner.Rect.Y >= 0); int actualWidth, actualHeight;
//down
MoveCorner(topRightCorner, false, true, 0, 5000);
Assert.IsTrue(topRightCorner.Rect.Y <= bottomBorder.Rect.Y);
//up-left
MoveCorner(topRightCorner, false, true, -5000, -5000);
Assert.IsTrue(topRightCorner.Rect.Y >= 0);
Assert.IsTrue(topRightCorner.Rect.X >= leftBorder.Rect.X);
//up-right //up-right
MoveCorner(topRightCorner, false, true, 5000, -5000); MoveCorner(topRightCorner, false, true, 5000, -5000);
actualHeight = bottomBorder.Rect.Y - topRightCorner.Rect.Y;
actualWidth = topRightCorner.Rect.X - leftBorder.Rect.X;
Assert.IsTrue(topRightCorner.Rect.Y >= 0); Assert.IsTrue(topRightCorner.Rect.Y >= 0);
Assert.IsTrue(leftBorder.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right); Assert.IsTrue(leftBorder.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right);
Assert.IsTrue(actualHeight > expectedHeight);
Assert.IsTrue(actualWidth > expectedWidth);
//to the left expectedHeight = actualHeight;
MoveCorner(topRightCorner, false, true, -5000, 0); expectedWidth = actualWidth;
Assert.IsTrue(topRightCorner.Rect.X >= leftBorder.Rect.X);
//to the right
MoveCorner(topRightCorner, false, true, 5000, 0);
Assert.IsTrue(leftBorder.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right);
//down-right
MoveCorner(topRightCorner, false, true, 5000, 5000);
Assert.IsTrue(topRightCorner.Rect.Y <= bottomBorder.Rect.Y);
Assert.IsTrue(leftBorder.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right);
//down-left //down-left
MoveCorner(topRightCorner, false, true, -5000, 5000); MoveCorner(topRightCorner, false, true, -5000, 5000);
actualHeight = bottomBorder.Rect.Y - topRightCorner.Rect.Y;
actualWidth = topRightCorner.Rect.X - leftBorder.Rect.X;
Assert.IsTrue(topRightCorner.Rect.Y <= bottomBorder.Rect.Y); Assert.IsTrue(topRightCorner.Rect.Y <= bottomBorder.Rect.Y);
Assert.IsTrue(topRightCorner.Rect.X >= leftBorder.Rect.X); Assert.IsTrue(topRightCorner.Rect.X >= leftBorder.Rect.X);
Assert.IsTrue(actualHeight < expectedHeight);
Assert.IsTrue(actualWidth < expectedWidth);
} }
[TestMethod] [TestMethod]
@@ -190,41 +192,32 @@ namespace PowerToysTests
Assert.IsNotNull(topBorder); Assert.IsNotNull(topBorder);
Assert.IsNotNull(rightBorder); Assert.IsNotNull(rightBorder);
//down int expectedWidth = rightBorder.Rect.X - bottomLeftCorner.Rect.X;
MoveCorner(bottomLeftCorner, true, false, 0, 5000); int expectedHeight = bottomLeftCorner.Rect.Y - topBorder.Rect.Y;
Assert.IsTrue(bottomLeftCorner.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom); int actualWidth, actualHeight;
//up
MoveCorner(bottomLeftCorner, true, false, 0, -5000);
Assert.IsTrue(bottomLeftCorner.Rect.Y >= topBorder.Rect.Y);
//down-right
MoveCorner(bottomLeftCorner, true, false, 5000, 5000);
Assert.IsTrue(bottomLeftCorner.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom);
Assert.IsTrue(bottomLeftCorner.Rect.X <= rightBorder.Rect.X);
//down-left
MoveCorner(bottomLeftCorner, true, false, -5000, 5000);
Assert.IsTrue(bottomLeftCorner.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom);
Assert.IsTrue(bottomLeftCorner.Rect.X >= 0);
//to the right
MoveCorner(bottomLeftCorner, true, false, 5000, 0);
Assert.IsTrue(bottomLeftCorner.Rect.X <= rightBorder.Rect.X);
//to the left
MoveCorner(bottomLeftCorner, true, false, -5000, 0);
Assert.IsTrue(bottomLeftCorner.Rect.X >= 0);
//up-left //up-left
MoveCorner(bottomLeftCorner, true, false, -5000, -5000);
Assert.IsTrue(bottomLeftCorner.Rect.Y >= topBorder.Rect.Y);
Assert.IsTrue(bottomLeftCorner.Rect.X >= 0);
//up-right
MoveCorner(bottomLeftCorner, true, false, 5000, -5000); MoveCorner(bottomLeftCorner, true, false, 5000, -5000);
actualHeight = bottomLeftCorner.Rect.Y - topBorder.Rect.Y;
actualWidth = rightBorder.Rect.X - bottomLeftCorner.Rect.X;
Assert.IsTrue(bottomLeftCorner.Rect.Y >= topBorder.Rect.Y); Assert.IsTrue(bottomLeftCorner.Rect.Y >= topBorder.Rect.Y);
Assert.IsTrue(bottomLeftCorner.Rect.X <= rightBorder.Rect.X); Assert.IsTrue(bottomLeftCorner.Rect.X <= rightBorder.Rect.X);
Assert.IsTrue(actualHeight < expectedHeight);
Assert.IsTrue(actualWidth < expectedWidth);
expectedHeight = actualHeight;
expectedWidth = actualWidth;
//down-right
MoveCorner(bottomLeftCorner, true, false, -5000, 5000);
actualHeight = bottomLeftCorner.Rect.Y - topBorder.Rect.Y;
actualWidth = rightBorder.Rect.X - bottomLeftCorner.Rect.X;
Assert.IsTrue(bottomLeftCorner.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom);
Assert.IsTrue(bottomLeftCorner.Rect.X >= 0);
Assert.IsTrue(actualHeight > expectedHeight);
Assert.IsTrue(actualWidth > expectedWidth);
} }
[TestMethod] [TestMethod]
@@ -237,41 +230,31 @@ namespace PowerToysTests
Assert.IsNotNull(topBorder); Assert.IsNotNull(topBorder);
Assert.IsNotNull(leftBorder); Assert.IsNotNull(leftBorder);
//to the right int expectedWidth = bottomRightCorner.Rect.X - leftBorder.Rect.X;
MoveCorner(bottomRightCorner, false, false, 5000, 0); int expectedHeight = bottomRightCorner.Rect.Y - topBorder.Rect.Y;
Assert.IsTrue(bottomRightCorner.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right); int actualWidth, actualHeight;
//to the left
MoveCorner(bottomRightCorner, false, false, -5000, 0);
Assert.IsTrue(bottomRightCorner.Rect.X >= leftBorder.Rect.X);
//down
MoveCorner(bottomRightCorner, false, false, 0, 5000);
Assert.IsTrue(bottomRightCorner.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom);
//up
MoveCorner(bottomRightCorner, false, false, 0, -5000);
Assert.IsTrue(bottomRightCorner.Rect.Y >= topBorder.Rect.Y);
//up-left //up-left
MoveCorner(bottomRightCorner, false, false, -5000, -5000); MoveCorner(bottomRightCorner, false, false, -5000, -5000);
actualHeight = bottomRightCorner.Rect.Y - topBorder.Rect.Y;
actualWidth = bottomRightCorner.Rect.X - leftBorder.Rect.X;
Assert.IsTrue(bottomRightCorner.Rect.Y >= topBorder.Rect.Y); Assert.IsTrue(bottomRightCorner.Rect.Y >= topBorder.Rect.Y);
Assert.IsTrue(bottomRightCorner.Rect.X >= leftBorder.Rect.X); Assert.IsTrue(bottomRightCorner.Rect.X >= leftBorder.Rect.X);
Assert.IsTrue(actualHeight < expectedHeight);
Assert.IsTrue(actualWidth < expectedWidth);
//up-right expectedHeight = actualHeight;
MoveCorner(bottomRightCorner, false, false, 5000, -5000); expectedWidth = actualWidth;
Assert.IsTrue(bottomRightCorner.Rect.Y >= topBorder.Rect.Y);
Assert.IsTrue(bottomRightCorner.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right);
//down-right //down-right
MoveCorner(bottomRightCorner, false, false, 5000, 5000); MoveCorner(bottomRightCorner, false, false, 5000, 5000);
actualHeight = bottomRightCorner.Rect.Y - topBorder.Rect.Y;
actualWidth = bottomRightCorner.Rect.X - leftBorder.Rect.X;
Assert.IsTrue(bottomRightCorner.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom); Assert.IsTrue(bottomRightCorner.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom);
Assert.IsTrue(bottomRightCorner.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right); Assert.IsTrue(bottomRightCorner.Rect.X <= Screen.PrimaryScreen.WorkingArea.Right);
Assert.IsTrue(actualHeight > expectedHeight);
//down-left
MoveCorner(bottomRightCorner, false, false, -5000, 5000);
Assert.IsTrue(bottomRightCorner.Rect.Y <= Screen.PrimaryScreen.WorkingArea.Bottom);
Assert.IsTrue(bottomRightCorner.Rect.X >= leftBorder.Rect.X);
} }
[ClassInitialize] [ClassInitialize]
@@ -285,17 +268,12 @@ namespace PowerToysTests
LaunchPowerToys(); LaunchPowerToys();
} }
OpenEditor(); OpenEditor();
OpenCustomLayouts(); OpenCustomLayouts();
//create canvas zone
OpenCreatorWindow("Create new custom", "Custom layout creator");
session.FindElementByAccessibilityId("newZoneButton").Click();
} }
[ClassCleanup] [ClassCleanup]
public static void ClassCleanup() public static void ClassCleanup()
{ {
new Actions(session).MoveToElement(session.FindElementByXPath("//Button[@Name=\"Cancel\"]")).Click().Perform();
CloseEditor(); CloseEditor();
TearDown(); TearDown();
} }
@@ -303,13 +281,15 @@ namespace PowerToysTests
[TestInitialize] [TestInitialize]
public void TestInitialize() public void TestInitialize()
{ {
//create canvas zone
OpenCreatorWindow("Create new custom", "Custom layout creator");
session.FindElementByAccessibilityId("newZoneButton").Click();
} }
[TestCleanup] [TestCleanup]
public void TestCleanup() public void TestCleanup()
{ {
new Actions(session).MoveToElement(session.FindElementByXPath("//Button[@Name=\"Cancel\"]")).Click().Perform();
} }
} }
} }

View File

@@ -23,7 +23,7 @@ namespace PowerToysTests
{ {
WindowsElement cancelButton = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]/Window/Button[@Name=\"Cancel\"]"); WindowsElement cancelButton = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]/Window/Button[@Name=\"Cancel\"]");
new Actions(session).MoveToElement(cancelButton).Click().Perform(); new Actions(session).MoveToElement(cancelButton).Click().Perform();
ShortWait(); WaitSeconds(1);
Assert.AreEqual(_initialZoneSettings, File.ReadAllText(_zoneSettingsPath), "Settings were changed"); Assert.AreEqual(_initialZoneSettings, File.ReadAllText(_zoneSettingsPath), "Settings were changed");
} }
@@ -31,7 +31,7 @@ namespace PowerToysTests
private void SaveTest(string type, string name, int zoneCount) private void SaveTest(string type, string name, int zoneCount)
{ {
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
ShortWait(); WaitSeconds(1);
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath)); JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
Assert.AreEqual(name, settings["custom-zone-sets"][0]["name"]); Assert.AreEqual(name, settings["custom-zone-sets"][0]["name"]);
@@ -149,7 +149,7 @@ namespace PowerToysTests
string name = "My custom zone layout name"; string name = "My custom zone layout name";
SetLayoutName(name); SetLayoutName(name);
SaveTest("canvas", name, 0); SaveTest("canvas", name, 0);
ShortWait(); WaitSeconds(1);
//rename layout //rename layout
OpenEditor(); OpenEditor();
@@ -168,7 +168,7 @@ namespace PowerToysTests
string name = "Name"; string name = "Name";
SetLayoutName(name); SetLayoutName(name);
SaveTest("canvas", name, 0); SaveTest("canvas", name, 0);
ShortWait(); WaitSeconds(1);
//save layout id //save layout id
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath)); JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
@@ -183,7 +183,7 @@ namespace PowerToysTests
//settings are saved on window closing //settings are saved on window closing
new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform();
ShortWait(); WaitSeconds(1);
//check settings //check settings
settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath)); settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
@@ -206,7 +206,7 @@ namespace PowerToysTests
SetLayoutName(name); SetLayoutName(name);
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
ShortWait(); WaitSeconds(1);
//remove layout //remove layout
OpenEditor(); OpenEditor();
@@ -217,7 +217,7 @@ namespace PowerToysTests
//settings are saved on window closing //settings are saved on window closing
new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform();
ShortWait(); WaitSeconds(1);
//check settings //check settings
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath)); JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
@@ -236,8 +236,7 @@ namespace PowerToysTests
SetLayoutName(name); SetLayoutName(name);
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
ShortWait();
//remove layout //remove layout
OpenEditor(); OpenEditor();
OpenCustomLayouts(); OpenCustomLayouts();
@@ -247,7 +246,7 @@ namespace PowerToysTests
//settings are saved on window closing //settings are saved on window closing
new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByAccessibilityId("PART_Close")).Click().Perform();
ShortWait(); WaitSeconds(1);
//check settings //check settings
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath)); JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
@@ -263,7 +262,7 @@ namespace PowerToysTests
OpenCreatorWindow("Create new custom", "Custom layout creator"); OpenCreatorWindow("Create new custom", "Custom layout creator");
SetLayoutName(name); SetLayoutName(name);
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
ShortWait(); WaitSeconds(1);
//save layout id //save layout id
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath)); JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
@@ -278,7 +277,7 @@ namespace PowerToysTests
//apply //apply
new Actions(session).MoveToElement(session.FindElementByName("Apply")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByName("Apply")).Click().Perform();
ShortWait(); WaitSeconds(1);
//check settings //check settings
settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath)); settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));

View File

@@ -59,11 +59,10 @@ namespace PowerToysTests
WindowsElement errorMessage = null; WindowsElement errorMessage = null;
try try
{ {
errorMessage = session.FindElementByName("FancyZones Editor Exception Handler"); errorMessage = WaitElementByName("FancyZones Editor Exception Handler");
if (errorMessage != null) if (errorMessage != null)
{ {
errorMessage.FindElementByName("OK").Click(); errorMessage.FindElementByName("OK").Click();
ShortWait();
} }
} }
catch (OpenQA.Selenium.WebDriverException) catch (OpenQA.Selenium.WebDriverException)
@@ -92,16 +91,12 @@ namespace PowerToysTests
Assert.IsNotNull(editorButton); Assert.IsNotNull(editorButton);
editorButton.Click(); editorButton.Click();
ShortWait();
TestEditorOpened(); TestEditorOpened();
} }
void OpenEditorByHotkey() void OpenEditorByHotkey()
{ {
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform(); new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
ShortWait();
TestEditorOpened(); TestEditorOpened();
} }

View File

@@ -37,7 +37,7 @@ namespace PowerToysTests
{ {
session.FindElementByAccessibilityId("ApplyTemplateButton").Click(); session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
ShortWait(); WaitSeconds(1);
Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount)); Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount));
OpenEditor(); OpenEditor();
@@ -57,7 +57,7 @@ namespace PowerToysTests
} }
session.FindElementByAccessibilityId("ApplyTemplateButton").Click(); session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
ShortWait(); WaitSeconds(1);
Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount)); Assert.AreEqual(editorZoneCountValue, GetEditZonesSetting<int>(editorZoneCount));
} }
@@ -74,7 +74,7 @@ namespace PowerToysTests
session.FindElementByAccessibilityId("ApplyTemplateButton").Click(); session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
ShortWait(); WaitSeconds(1);
Assert.AreNotEqual(spaceAroundSettingValue, GetEditZonesSetting<bool>(editorShowSpacing)); Assert.AreNotEqual(spaceAroundSettingValue, GetEditZonesSetting<bool>(editorShowSpacing));
} }
@@ -89,7 +89,7 @@ namespace PowerToysTests
bool editorShowSpacingValue = spaceAroundSetting.Selected; bool editorShowSpacingValue = spaceAroundSetting.Selected;
session.FindElementByAccessibilityId("ApplyTemplateButton").Click(); session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
ShortWait(); WaitSeconds(1);
string[] validValues = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; string[] validValues = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
@@ -102,7 +102,7 @@ namespace PowerToysTests
paddingValue.SendKeys(editorSpacingValue); paddingValue.SendKeys(editorSpacingValue);
session.FindElementByAccessibilityId("ApplyTemplateButton").Click(); session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
ShortWait(); WaitSeconds(1);
Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing)); Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing));
Assert.AreEqual(editorSpacingValue, GetEditZonesSetting<string>(editorSpacing)); Assert.AreEqual(editorSpacingValue, GetEditZonesSetting<string>(editorSpacing));
@@ -118,7 +118,7 @@ namespace PowerToysTests
bool editorShowSpacingValue = spaceAroundSetting.Selected; bool editorShowSpacingValue = spaceAroundSetting.Selected;
session.FindElementByAccessibilityId("ApplyTemplateButton").Click(); session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
ShortWait(); WaitSeconds(1);
string[] invalidValues = { "!", "/", "<", "?", "D", "Z", "]", "m", "}", "1.5", "2,5" }; string[] invalidValues = { "!", "/", "<", "?", "D", "Z", "]", "m", "}", "1.5", "2,5" };
@@ -133,7 +133,7 @@ namespace PowerToysTests
paddingValue.SendKeys(value); paddingValue.SendKeys(value);
session.FindElementByAccessibilityId("ApplyTemplateButton").Click(); session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
ShortWait(); WaitSeconds(1);
Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing)); Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting<bool>(editorShowSpacing));
Assert.AreEqual(editorSpacingValue, GetEditZonesSetting<string>(editorSpacing)); Assert.AreEqual(editorSpacingValue, GetEditZonesSetting<string>(editorSpacing));

View File

@@ -18,7 +18,7 @@ namespace PowerToysTests
{ {
WindowsElement cancelButton = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]/Window/Button[@Name=\"Cancel\"]"); WindowsElement cancelButton = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]/Window/Button[@Name=\"Cancel\"]");
new Actions(session).MoveToElement(cancelButton).Click().Perform(); new Actions(session).MoveToElement(cancelButton).Click().Perform();
ShortWait(); WaitSeconds(1);
Assert.AreEqual(_defaultZoneSettings, File.ReadAllText(_zoneSettingsPath), "Settings were changed"); Assert.AreEqual(_defaultZoneSettings, File.ReadAllText(_zoneSettingsPath), "Settings were changed");
} }
@@ -26,7 +26,7 @@ namespace PowerToysTests
private void SaveTest() private void SaveTest()
{ {
new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform(); new Actions(session).MoveToElement(session.FindElementByName("Save and apply")).Click().Perform();
ShortWait(); WaitSeconds(1);
JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath)); JObject settings = JObject.Parse(File.ReadAllText(_zoneSettingsPath));
Assert.AreEqual("Custom Layout 1", settings["custom-zone-sets"][0]["name"]); Assert.AreEqual("Custom Layout 1", settings["custom-zone-sets"][0]["name"]);
@@ -188,7 +188,6 @@ namespace PowerToysTests
if (editorWindow != null) if (editorWindow != null)
{ {
editorWindow.SendKeys(OpenQA.Selenium.Keys.Alt + OpenQA.Selenium.Keys.F4); editorWindow.SendKeys(OpenQA.Selenium.Keys.Alt + OpenQA.Selenium.Keys.F4);
ShortWait();
} }
} }
catch(OpenQA.Selenium.WebDriverException) catch(OpenQA.Selenium.WebDriverException)

View File

@@ -1,4 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows; using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Interactions; using OpenQA.Selenium.Interactions;
@@ -17,8 +17,10 @@ namespace PowerToysTests
protected static void OpenEditor() protected static void OpenEditor()
{ {
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform(); new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
ShortWait(); //editorWindow = WaitElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
editorWindow = session.FindElementByXPath("//Window[@Name=\"FancyZones Editor\"]"); //may not find editor by name in 0.16.1
editorWindow = WaitElementByAccessibilityId("MainWindow1");
Assert.IsNotNull(editorWindow, "Couldn't find editor window");
} }
protected static void CloseEditor() protected static void CloseEditor()
@@ -28,7 +30,6 @@ namespace PowerToysTests
if (editorWindow != null) if (editorWindow != null)
{ {
editorWindow.SendKeys(OpenQA.Selenium.Keys.Alt + OpenQA.Selenium.Keys.F4); editorWindow.SendKeys(OpenQA.Selenium.Keys.Alt + OpenQA.Selenium.Keys.F4);
ShortWait();
} }
} }
catch (OpenQA.Selenium.WebDriverException) catch (OpenQA.Selenium.WebDriverException)

View File

@@ -25,8 +25,6 @@ namespace PowerToysTests
private static void Init() private static void Init()
{ {
OpenSettings(); OpenSettings();
ShortWait();
OpenFancyZonesSettings(); OpenFancyZonesSettings();
_saveButton = session.FindElementByName("Save"); _saveButton = session.FindElementByName("Save");
@@ -94,7 +92,7 @@ namespace PowerToysTests
Assert.AreEqual(expected.ToString() + "\r\n", editor.Text); Assert.AreEqual(expected.ToString() + "\r\n", editor.Text);
SaveChanges(); SaveChanges();
ShortWait(); WaitSeconds(1);
int value = GetPropertyValue<int>("fancyzones_highlight_opacity"); int value = GetPropertyValue<int>("fancyzones_highlight_opacity");
Assert.AreEqual(expected, value); Assert.AreEqual(expected, value);
@@ -215,7 +213,7 @@ namespace PowerToysTests
action.Perform(); action.Perform();
SaveChanges(); SaveChanges();
ShortWait(); WaitSeconds(1);
//Assert.AreEqual(expectedText, input.Text); //Assert.AreEqual(expectedText, input.Text);
@@ -235,7 +233,7 @@ namespace PowerToysTests
//black on the bottom //black on the bottom
new Actions(session).MoveToElement(saturationAndBrightness).ClickAndHold().MoveByOffset(0, satRect.Height).Release().Perform(); new Actions(session).MoveToElement(saturationAndBrightness).ClickAndHold().MoveByOffset(0, satRect.Height).Release().Perform();
ShortWait(); WaitSeconds(1);
Assert.AreEqual("0\r\n", red.Text); Assert.AreEqual("0\r\n", red.Text);
Assert.AreEqual("0\r\n", green.Text); Assert.AreEqual("0\r\n", green.Text);
@@ -243,7 +241,7 @@ namespace PowerToysTests
Assert.AreEqual("000000\r\n", hex.Text); Assert.AreEqual("000000\r\n", hex.Text);
SaveChanges(); SaveChanges();
ShortWait(); WaitSeconds(1);
Assert.AreEqual("#000000", GetPropertyValue<string>(propertyName)); Assert.AreEqual("#000000", GetPropertyValue<string>(propertyName));
//white in left corner //white in left corner
@@ -254,7 +252,7 @@ namespace PowerToysTests
Assert.AreEqual("ffffff\r\n", hex.Text); Assert.AreEqual("ffffff\r\n", hex.Text);
SaveChanges(); SaveChanges();
ShortWait(); WaitSeconds(1);
Assert.AreEqual("#ffffff", GetPropertyValue<string>(propertyName)); Assert.AreEqual("#ffffff", GetPropertyValue<string>(propertyName));
//color in right corner //color in right corner
@@ -266,7 +264,7 @@ namespace PowerToysTests
Assert.AreEqual("ff0000\r\n", hex.Text); Assert.AreEqual("ff0000\r\n", hex.Text);
SaveChanges(); SaveChanges();
ShortWait(); WaitSeconds(1);
Assert.AreEqual("#ff0000", GetPropertyValue<string>(propertyName)); Assert.AreEqual("#ff0000", GetPropertyValue<string>(propertyName));
} }
@@ -299,9 +297,10 @@ namespace PowerToysTests
toggle.Click(); toggle.Click();
SaveChanges(); SaveChanges();
ShortWait();
} }
WaitSeconds(1);
//check saved settings //check saved settings
JObject savedProps = GetProperties(); JObject savedProps = GetProperties();
Assert.AreNotEqual(toggleValues[0], GetPropertyValue<bool>(savedProps, "fancyzones_shiftDrag")); Assert.AreNotEqual(toggleValues[0], GetPropertyValue<bool>(savedProps, "fancyzones_shiftDrag"));
@@ -339,7 +338,7 @@ namespace PowerToysTests
} }
SaveChanges(); SaveChanges();
ShortWait(); WaitSeconds(1);
JObject savedProps = GetProperties(); JObject savedProps = GetProperties();
Assert.AreEqual(toggleValues[0], GetPropertyValue<bool>(savedProps, "fancyzones_shiftDrag")); Assert.AreEqual(toggleValues[0], GetPropertyValue<bool>(savedProps, "fancyzones_shiftDrag"));
@@ -396,7 +395,7 @@ namespace PowerToysTests
Actions action = new Actions(session); Actions action = new Actions(session);
action.MoveToElement(editor).MoveByOffset(editorRect.Width / 2 + 10, -editorRect.Height / 4).Perform(); action.MoveToElement(editor).MoveByOffset(editorRect.Width / 2 + 10, -editorRect.Height / 4).Perform();
ShortWait(); WaitSeconds(1);
action.Click().Perform(); action.Click().Perform();
Assert.AreEqual("100\r\n", editor.Text); Assert.AreEqual("100\r\n", editor.Text);
@@ -421,7 +420,7 @@ namespace PowerToysTests
Actions action = new Actions(session); Actions action = new Actions(session);
action.MoveToElement(editor).MoveByOffset(editorRect.Width / 2 + 10, editorRect.Height / 4).Perform(); action.MoveToElement(editor).MoveByOffset(editorRect.Width / 2 + 10, editorRect.Height / 4).Perform();
ShortWait(); WaitSeconds(1);
action.Click().Perform(); action.Click().Perform();
Assert.AreEqual("0\r\n", editor.Text); Assert.AreEqual("0\r\n", editor.Text);
@@ -494,7 +493,7 @@ namespace PowerToysTests
Assert.AreEqual("152", hue.Text); Assert.AreEqual("152", hue.Text);
SaveChanges(); SaveChanges();
ShortWait(); WaitSeconds(1);
Assert.AreEqual("#63c99a", GetPropertyValue<string>("fancyzones_zoneHighlightColor")); Assert.AreEqual("#63c99a", GetPropertyValue<string>("fancyzones_zoneHighlightColor"));
} }
@@ -565,7 +564,7 @@ namespace PowerToysTests
input.SendKeys(inputValue); input.SendKeys(inputValue);
SaveChanges(); SaveChanges();
ClearInput(input); ClearInput(input);
ShortWait(); WaitSeconds(1);
Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps")); Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps"));
//invalid //invalid
@@ -573,28 +572,28 @@ namespace PowerToysTests
input.SendKeys(inputValue); input.SendKeys(inputValue);
SaveChanges(); SaveChanges();
ClearInput(input); ClearInput(input);
ShortWait(); WaitSeconds(1);
Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps")); Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps"));
inputValue = "Notepad,Chrome"; inputValue = "Notepad,Chrome";
input.SendKeys(inputValue); input.SendKeys(inputValue);
SaveChanges(); SaveChanges();
ClearInput(input); ClearInput(input);
ShortWait(); WaitSeconds(1);
Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps")); Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps"));
inputValue = "Note*"; inputValue = "Note*";
input.SendKeys(inputValue); input.SendKeys(inputValue);
SaveChanges(); SaveChanges();
ClearInput(input); ClearInput(input);
ShortWait(); WaitSeconds(1);
Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps")); Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps"));
inputValue = "Кириллица"; inputValue = "Кириллица";
input.SendKeys(inputValue); input.SendKeys(inputValue);
SaveChanges(); SaveChanges();
ClearInput(input); ClearInput(input);
ShortWait(); WaitSeconds(1);
Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps")); Assert.AreEqual(inputValue, GetPropertyValue<string>("fancyzones_excluded_apps"));
} }

View File

@@ -13,6 +13,8 @@ namespace PowerToysTests
public class PowerToysSession public class PowerToysSession
{ {
protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723"; protected const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
protected const string AppPath = "C:\\Program Files\\PowerToys\\PowerToys.exe";
protected static WindowsDriver<WindowsElement> session; protected static WindowsDriver<WindowsElement> session;
protected static bool isPowerToysLaunched = false; protected static bool isPowerToysLaunched = false;
protected static WindowsElement trayButton; protected static WindowsElement trayButton;
@@ -66,14 +68,27 @@ namespace PowerToysTests
{ {
Thread.Sleep(TimeSpan.FromSeconds(seconds)); Thread.Sleep(TimeSpan.FromSeconds(seconds));
} }
public static void ShortWait() //Trying to find element by XPath
{ protected static WindowsElement WaitElementByName(string name, double maxTime = 10)
Thread.Sleep(TimeSpan.FromSeconds(0.5)); {
WindowsElement result = null;
Stopwatch timer = new Stopwatch();
timer.Start();
while (timer.Elapsed < TimeSpan.FromSeconds(maxTime))
{
try
{
result = session.FindElementByName(name);
}
catch { }
return result;
}
return null;
} }
//Trying to find element by XPath //Trying to find element by XPath
protected WindowsElement WaitElementByXPath(string xPath, double maxTime = 10) protected static WindowsElement WaitElementByXPath(string xPath, double maxTime = 10)
{ {
WindowsElement result = null; WindowsElement result = null;
Stopwatch timer = new Stopwatch(); Stopwatch timer = new Stopwatch();
@@ -85,17 +100,13 @@ namespace PowerToysTests
result = session.FindElementByXPath(xPath); result = session.FindElementByXPath(xPath);
} }
catch { } catch { }
if (result != null) return result;
{
return result;
}
} }
Assert.IsNotNull(result);
return null; return null;
} }
//Trying to find element by AccessibilityId //Trying to find element by AccessibilityId
protected WindowsElement WaitElementByAccessibilityId(string accessibilityId, double maxTime = 10) protected static WindowsElement WaitElementByAccessibilityId(string accessibilityId, double maxTime = 10)
{ {
WindowsElement result = null; WindowsElement result = null;
Stopwatch timer = new Stopwatch(); Stopwatch timer = new Stopwatch();
@@ -107,12 +118,8 @@ namespace PowerToysTests
result = session.FindElementByAccessibilityId(accessibilityId); result = session.FindElementByAccessibilityId(accessibilityId);
} }
catch { } catch { }
if (result != null) return result;
{
return result;
}
} }
Assert.IsNotNull(result);
return null; return null;
} }
@@ -125,13 +132,11 @@ namespace PowerToysTests
public static void OpenFancyZonesSettings() public static void OpenFancyZonesSettings()
{ {
WindowsElement fzNavigationButton = session.FindElementByXPath("//Button[@Name=\"FancyZones\"]"); WindowsElement fzNavigationButton = WaitElementByXPath("//Button[@Name=\"FancyZones\"]");
Assert.IsNotNull(fzNavigationButton); Assert.IsNotNull(fzNavigationButton);
fzNavigationButton.Click(); fzNavigationButton.Click();
fzNavigationButton.Click(); fzNavigationButton.Click();
ShortWait();
} }
public static void CloseSettings() public static void CloseSettings()
@@ -157,7 +162,7 @@ namespace PowerToysTests
try try
{ {
WindowsElement pt = session.FindElementByXPath("//Button[@Name=\"PowerToys\"]"); WindowsElement pt = WaitElementByXPath("//Button[@Name=\"PowerToys\"]");
isLaunched = (pt != null); isLaunched = (pt != null);
} }
catch(OpenQA.Selenium.WebDriverException) catch(OpenQA.Selenium.WebDriverException)
@@ -174,11 +179,9 @@ namespace PowerToysTests
try try
{ {
AppiumOptions opts = new AppiumOptions(); AppiumOptions opts = new AppiumOptions();
opts.PlatformName = "Windows"; opts.PlatformName = "Windows";
opts.AddAdditionalCapability("platformVersion", "10"); opts.AddAdditionalCapability("app", AppPath);
opts.AddAdditionalCapability("deviceName", "WindowsPC");
opts.AddAdditionalCapability("app", "C:/Program Files/PowerToys/PowerToys.exe");
WindowsDriver<WindowsElement> driver = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opts); WindowsDriver<WindowsElement> driver = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), opts);
Assert.IsNotNull(driver); Assert.IsNotNull(driver);
driver.LaunchApp(); driver.LaunchApp();
@@ -195,13 +198,12 @@ namespace PowerToysTests
public static void ExitPowerToys() public static void ExitPowerToys()
{ {
trayButton.Click(); trayButton.Click();
ShortWait();
WindowsElement pt = session.FindElementByXPath("//Button[@Name=\"PowerToys\"]"); WindowsElement pt = WaitElementByXPath("//Button[@Name=\"PowerToys\"]");
Assert.IsNotNull(pt, "Couldn't find \'PowerToys\' button");
new Actions(session).MoveToElement(pt).ContextClick().Perform(); new Actions(session).MoveToElement(pt).ContextClick().Perform();
ShortWait();
WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click();
session.FindElementByXPath("//MenuItem[@Name=\"Exit\"]").Click();
trayButton.Click(); //close tray trayButton.Click(); //close tray
isPowerToysLaunched = false; isPowerToysLaunched = false;
} }

View File

@@ -15,10 +15,9 @@ namespace PowerToysTests
public void SettingsOpen() public void SettingsOpen()
{ {
OpenSettings(); OpenSettings();
ShortWait();
//check settings window opened //check settings window opened
WindowsElement settingsWindow = session.FindElementByName("PowerToys Settings"); WindowsElement settingsWindow = WaitElementByName("PowerToys Settings");
Assert.IsNotNull(settingsWindow); Assert.IsNotNull(settingsWindow);
isSettingsOpened = true; isSettingsOpened = true;
@@ -36,14 +35,12 @@ namespace PowerToysTests
Assert.IsNotNull(pt); Assert.IsNotNull(pt);
new Actions(session).MoveToElement(pt).ContextClick().Perform(); new Actions(session).MoveToElement(pt).ContextClick().Perform();
ShortWait();
//open settings //open settings
session.FindElementByXPath("//MenuItem[@Name=\"Settings\"]").Click(); WaitElementByXPath("//MenuItem[@Name=\"Settings\"]").Click();
ShortWait();
//check settings window opened //check settings window opened
WindowsElement settingsWindow = session.FindElementByName("PowerToys Settings"); WindowsElement settingsWindow = WaitElementByName("PowerToys Settings");
Assert.IsNotNull(settingsWindow); Assert.IsNotNull(settingsWindow);
isSettingsOpened = true; isSettingsOpened = true;
@@ -62,12 +59,10 @@ namespace PowerToysTests
Assert.IsNotNull(powerToys); Assert.IsNotNull(powerToys);
new Actions(session).MoveToElement(powerToys).ContextClick().Perform(); new Actions(session).MoveToElement(powerToys).ContextClick().Perform();
ShortWait();
//exit //exit
session.FindElementByXPath("//MenuItem[@Name=\"Exit\"]").Click(); WaitElementByXPath("//MenuItem[@Name=\"Exit\"]").Click();
ShortWait();
//check PowerToys exited //check PowerToys exited
powerToys = null; powerToys = null;
try try
@@ -82,8 +77,6 @@ namespace PowerToysTests
} }
LaunchPowerToys(); LaunchPowerToys();
ShortWait();
Assert.IsNull(powerToys); Assert.IsNull(powerToys);
} }