[WinAppDriver tests] Affection on user setting files fix (#4186)

This commit is contained in:
Seraphima Zykova
2020-06-19 11:09:12 +03:00
committed by GitHub
parent c78e6588ad
commit 90efc5740f
13 changed files with 315 additions and 190 deletions

View File

@@ -261,6 +261,9 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context, false);
if (session == null)
return;
ResetSettings();
if (!isPowerToysLaunched)
@@ -281,6 +284,9 @@ namespace PowerToysTests
[TestInitialize]
public void TestInitialize()
{
if (session == null)
return;
//create canvas zone
OpenCreatorWindow("Create new custom", "Custom layout creator");
session.FindElementByAccessibilityId("newZoneButton").Click();
@@ -289,6 +295,9 @@ namespace PowerToysTests
[TestCleanup]
public void TestCleanup()
{
if (session == null)
return;
new Actions(session).MoveToElement(session.FindElementByXPath("//Button[@Name=\"Cancel\"]")).Click().Perform();
}
}

View File

@@ -292,6 +292,9 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context, false);
if (session == null)
return;
ResetSettings();
}
@@ -304,6 +307,9 @@ namespace PowerToysTests
[TestInitialize]
public void TestInitialize()
{
if (session == null)
return;
if (!isPowerToysLaunched)
{
LaunchPowerToys();

View File

@@ -397,6 +397,9 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context, false);
if (session == null)
return;
ResetSettings();
if (!isPowerToysLaunched)

View File

@@ -233,6 +233,9 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context, false);
if (session == null)
return;
ResetDefaultFancyZonesSettings(true);
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -179,6 +179,9 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context, false);
if (session == null)
return;
ResetSettings();
}

View File

@@ -68,6 +68,9 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context, false);
if (session == null)
return;
ResetDefaultFancyZonesSettings(true);
}
@@ -81,6 +84,9 @@ namespace PowerToysTests
[TestInitialize]
public void TestInitialize()
{
if (session == null)
return;
OpenEditor();
OpenTemplates();
}

View File

@@ -157,6 +157,9 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context, false);
if (session == null)
return;
ResetDefaultFancyZonesSettings(false);
ResetDefaultZoneSettings(true);
}
@@ -171,6 +174,9 @@ namespace PowerToysTests
[TestInitialize]
public void TestInitialize()
{
if (session == null)
return;
if (!isPowerToysLaunched)
{
LaunchPowerToys();

View File

@@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;
using OpenQA.Selenium.Interactions;
using System;
namespace PowerToysTests
{
@@ -16,13 +17,20 @@ namespace PowerToysTests
protected static void OpenEditor()
{
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
WaitSeconds(2);
//editorWindow = WaitElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
editorWindow = WaitElementByName("FancyZones Editor");
//may not find editor by name in 0.16.1
//editorWindow = WaitElementByAccessibilityId("MainWindow1");
Assert.IsNotNull(editorWindow, "Couldn't find editor window");
try
{
new Actions(session).KeyDown(OpenQA.Selenium.Keys.Command).SendKeys("`").KeyUp(OpenQA.Selenium.Keys.Command).Perform();
WaitSeconds(2);
//editorWindow = WaitElementByXPath("//Window[@Name=\"FancyZones Editor\"]");
editorWindow = WaitElementByName("FancyZones Editor");
//may not find editor by name in 0.16.1
//editorWindow = WaitElementByAccessibilityId("MainWindow1");
Assert.IsNotNull(editorWindow, "Couldn't find editor window");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
protected static void CloseEditor()
@@ -42,28 +50,49 @@ namespace PowerToysTests
protected static void OpenCustomLayouts()
{
WindowsElement customsTab = session.FindElementByName("Custom");
customsTab.Click();
string isSelected = customsTab.GetAttribute("SelectionItem.IsSelected");
Assert.AreEqual("True", isSelected, "Custom tab cannot be opened");
try
{
WindowsElement customsTab = session.FindElementByName("Custom");
customsTab.Click();
string isSelected = customsTab.GetAttribute("SelectionItem.IsSelected");
Assert.AreEqual("True", isSelected, "Custom tab cannot be opened");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
protected static void OpenTemplates()
{
WindowsElement templatesTab = session.FindElementByName("Templates");
templatesTab.Click();
string isSelected = templatesTab.GetAttribute("SelectionItem.IsSelected");
Assert.AreEqual("True", isSelected, "Templates tab cannot be opened");
try
{
WindowsElement templatesTab = session.FindElementByName("Templates");
templatesTab.Click();
string isSelected = templatesTab.GetAttribute("SelectionItem.IsSelected");
Assert.AreEqual("True", isSelected, "Templates tab cannot be opened");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
protected static void OpenCreatorWindow(string tabName, string creatorWindowName, string buttonId = "EditCustomButton")
{
string elementXPath = "//Text[@Name=\"" + tabName + "\"]";
WaitElementByXPath(elementXPath).Click();
WaitElementByAccessibilityId(buttonId).Click();
try
{
string elementXPath = "//Text[@Name=\"" + tabName + "\"]";
WaitElementByXPath(elementXPath).Click();
WaitElementByAccessibilityId(buttonId).Click();
WindowsElement creatorWindow = WaitElementByName(creatorWindowName);
Assert.IsNotNull(creatorWindow, "Creator window didn't open");
WindowsElement creatorWindow = WaitElementByName(creatorWindowName);
Assert.IsNotNull(creatorWindow, "Creator window didn't open");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
protected void ZoneCountTest(int canvasZoneCount, int gridZoneCount)

View File

@@ -713,6 +713,9 @@ namespace PowerToysTests
public static void ClassInitialize(TestContext context)
{
Setup(context);
if (session == null)
return;
Init();
}
@@ -740,6 +743,9 @@ namespace PowerToysTests
[TestInitialize]
public void TestInitialize()
{
if (session == null)
return;
try
{
_initialSettingsJson = JObject.Parse(_initialSettings);