replace cilcks

This commit is contained in:
seraphima 2024-03-18 21:49:03 +01:00
parent efb235536f
commit fb80c851bb
11 changed files with 95 additions and 122 deletions

View File

@ -283,7 +283,7 @@ namespace Microsoft.FancyZonesEditor.UITests
slider.SendKeys(Keys.Right);
slider.SendKeys(Keys.Right);
var expectedFirstLayoutZoneCount = int.Parse(slider.Text!, CultureInfo.InvariantCulture);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(slider); // let the dialog window close
// apply the layout on the second monitor, set different parameters
@ -294,7 +294,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.IsNotNull(slider);
slider.SendKeys(Keys.Left);
var expectedSecondLayoutZoneCount = int.Parse(slider.Text!, CultureInfo.InvariantCulture);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the layout on the first monitor wasn't changed
@ -303,7 +303,7 @@ namespace Microsoft.FancyZonesEditor.UITests
slider = _session?.FindByAccessibilityId(AccessibilityId.TemplateZoneSlider);
Assert.IsNotNull(slider);
Assert.AreEqual(expectedFirstLayoutZoneCount, int.Parse(slider.Text!, CultureInfo.InvariantCulture));
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
// check the file

View File

@ -229,7 +229,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickCopyLayout();
// verify the layout is copied
_session?.ClickSave();
_session?.Click(ElementName.Save);
Assert.IsNotNull(_session?.GetLayout(copiedLayoutName)); // new name is presented
// verify the file
@ -241,12 +241,12 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickEditLayout(Constants.TemplateLayoutNames[Constants.TemplateLayouts.PriorityGrid]);
var horizontalDefaultButton = _session?.GetHorizontalDefaultButton(true);
Assert.IsNotNull(horizontalDefaultButton);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.ClickEditLayout(copiedLayoutName);
horizontalDefaultButton = _session?.GetHorizontalDefaultButton(false);
Assert.IsNotNull(horizontalDefaultButton);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// verify the default layouts file wasn't changed
var defaultLayouts = new DefaultLayouts();
@ -296,7 +296,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickCopyLayout();
// verify the layout is copied
_session?.ClickSave();
_session?.Click(ElementName.Save);
Assert.IsNotNull(_session?.GetLayout(copiedLayoutName)); // new name is presented
// verify the file
@ -308,12 +308,12 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickEditLayout(CustomLayouts.CustomLayouts[0].Name);
var horizontalDefaultButton = _session?.GetVerticalDefaultButton(true);
Assert.IsNotNull(horizontalDefaultButton);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.ClickEditLayout(copiedLayoutName);
horizontalDefaultButton = _session?.GetVerticalDefaultButton(false);
Assert.IsNotNull(horizontalDefaultButton);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// verify the default layouts file wasn't changed
var defaultLayouts = new DefaultLayouts();
@ -329,7 +329,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickCopyLayout();
// verify the layout is copied
_session?.ClickSave();
_session?.Click(ElementName.Save);
Assert.IsNotNull(_session?.GetLayout(copiedLayoutName)); // new name is presented
// verify the file
@ -342,13 +342,13 @@ namespace Microsoft.FancyZonesEditor.UITests
var hotkeyComboBox = _session?.FindByAccessibilityId(AccessibilityId.HotkeyComboBox);
Assert.IsNotNull(hotkeyComboBox);
Assert.AreEqual("0", hotkeyComboBox.Text);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.ClickEditLayout(copiedLayoutName);
hotkeyComboBox = _session?.FindByAccessibilityId(AccessibilityId.HotkeyComboBox);
Assert.IsNotNull(hotkeyComboBox);
Assert.AreEqual("None", hotkeyComboBox.Text);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// verify the hotkey file wasn't changed
var hotkeys = new LayoutHotkeys();

View File

@ -151,9 +151,9 @@ namespace Microsoft.FancyZonesEditor.UITests
public void CreateWithDefaultName()
{
string name = "Custom layout 1";
_session?.ClickCreateNewLayout();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewLayoutButton));
_session?.ClickConfirm();
_session?.ClickSave();
_session?.Click(ElementName.Save);
// verify new layout presented
Assert.IsNotNull(_session?.GetLayout(name));
@ -169,13 +169,13 @@ namespace Microsoft.FancyZonesEditor.UITests
public void CreateWithCustomName()
{
string name = "Layout Name";
_session?.ClickCreateNewLayout();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewLayoutButton));
var input = _session?.FindByClassName(ClassName.TextBox);
Assert.IsNotNull(input);
input.Clear();
input.SendKeys(name);
_session?.ClickConfirm();
_session?.ClickSave();
_session?.Click(ElementName.Save);
// verify new layout presented
Assert.IsNotNull(_session?.GetLayout(name));
@ -191,10 +191,10 @@ namespace Microsoft.FancyZonesEditor.UITests
public void CreateGrid()
{
Constants.CustomLayoutType type = Constants.CustomLayoutType.Grid;
_session?.ClickCreateNewLayout();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewLayoutButton));
_session?.SelectNewLayoutType(type);
_session?.ClickConfirm();
_session?.ClickSave();
_session?.Click(ElementName.Save);
// check the file
var customLayouts = new CustomLayouts();
@ -207,10 +207,10 @@ namespace Microsoft.FancyZonesEditor.UITests
public void CreateCanvas()
{
Constants.CustomLayoutType type = Constants.CustomLayoutType.Canvas;
_session?.ClickCreateNewLayout();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewLayoutButton));
_session?.SelectNewLayoutType(type);
_session?.ClickConfirm();
_session?.ClickSave();
_session?.Click(ElementName.Save);
// check the file
var customLayouts = new CustomLayouts();
@ -223,10 +223,10 @@ namespace Microsoft.FancyZonesEditor.UITests
public void CancelGridCreation()
{
Constants.CustomLayoutType type = Constants.CustomLayoutType.Grid;
_session?.ClickCreateNewLayout();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewLayoutButton));
_session?.SelectNewLayoutType(type);
_session?.ClickConfirm();
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var customLayouts = new CustomLayouts();
@ -238,10 +238,10 @@ namespace Microsoft.FancyZonesEditor.UITests
public void CancelCanvasCreation()
{
Constants.CustomLayoutType type = Constants.CustomLayoutType.Canvas;
_session?.ClickCreateNewLayout();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewLayoutButton));
_session?.SelectNewLayoutType(type);
_session?.ClickConfirm();
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var customLayouts = new CustomLayouts();

View File

@ -246,7 +246,7 @@ namespace Microsoft.FancyZonesEditor.UITests
input.SendKeys(newName);
// verify new name
_session?.ClickSave();
_session?.Click(ElementName.Save);
Assert.IsNull(_session?.GetLayout(oldName)); // previous name isn't presented
Assert.IsNotNull(_session?.GetLayout(newName)); // new name is presented
}
@ -265,7 +265,7 @@ namespace Microsoft.FancyZonesEditor.UITests
input.SendKeys(newName);
// verify new name
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
Assert.IsNotNull(_session?.GetLayout(oldName));
Assert.IsNull(_session?.GetLayout(newName));
}
@ -284,7 +284,7 @@ namespace Microsoft.FancyZonesEditor.UITests
new CustomLayouts().GridFromJsonElement(layout.Info.GetRawText()).SensitivityRadius;
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider);
}
}
@ -307,7 +307,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -334,7 +334,7 @@ namespace Microsoft.FancyZonesEditor.UITests
new CustomLayouts().CanvasFromJsonElement(layout.Info.GetRawText()).SensitivityRadius :
new CustomLayouts().GridFromJsonElement(layout.Info.GetRawText()).SensitivityRadius;
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -371,7 +371,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var expected = new CustomLayouts().GridFromJsonElement(layout.Info.GetRawText()).Spacing;
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
}
}
@ -388,7 +388,7 @@ namespace Microsoft.FancyZonesEditor.UITests
slider.SendKeys(Keys.Right);
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -408,7 +408,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var slider = _session?.FindByAccessibilityId(AccessibilityId.SpacingSlider);
Assert.IsNotNull(slider);
slider.SendKeys(Keys.Right);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -432,7 +432,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreEqual(expected, toggle.Selected, "Toggle value not changed");
Assert.AreEqual(expected, _session?.FindByAccessibilityId(AccessibilityId.SpacingSlider)?.Enabled);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(toggle); // let the dialog window close
// verify the file
@ -455,7 +455,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreNotEqual(expected, toggle.Selected, "Toggle value not changed");
Assert.AreNotEqual(expected, _session?.FindByAccessibilityId(AccessibilityId.SpacingSlider)?.Enabled);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(toggle); // let the dialog window close
// verify the file

View File

@ -9,6 +9,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
using static FancyZonesEditorCommon.Data.CustomLayouts;
using static FancyZonesEditorCommon.Data.DefaultLayouts;
using static FancyZonesEditorCommon.Data.EditorParameters;
using static Microsoft.FancyZonesEditor.UnitTests.Utils.FancyZonesEditorSession;
namespace Microsoft.FancyZonesEditor.UITests
{
@ -268,7 +269,7 @@ namespace Microsoft.FancyZonesEditor.UITests
verticalDefaultButton?.Click();
// cancel
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(horizontalDefaultButton!);
// check that default layouts weren't changed
@ -287,7 +288,7 @@ namespace Microsoft.FancyZonesEditor.UITests
verticalDefaultButton?.Click();
// cancel
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(horizontalDefaultButton!);
// check that default layout was changed
@ -314,7 +315,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var verticalDefaultButton = _session?.GetVerticalDefaultButton(isCheckedVertical);
Assert.IsNotNull(verticalDefaultButton, "Incorrect vertical default layout set at " + name);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(horizontalDefaultButton!);
}
}
@ -333,7 +334,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var verticalDefaultButton = _session?.GetVerticalDefaultButton(isCheckedVertical);
Assert.IsNotNull(verticalDefaultButton, "Incorrect vertical custom layout set at " + layout.Name);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(horizontalDefaultButton!);
}
}

View File

@ -233,7 +233,7 @@ namespace Microsoft.FancyZonesEditor.UITests
{
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
_session?.ClickEditLayout(deletedLayout);
_session?.ClickDeleteLayout();
_session?.Click(_session.FindByAccessibilityId(AccessibilityId.DeleteLayoutButton));
_session?.ClickConfirmDialog();
_session?.WaitFor(1);
@ -252,7 +252,7 @@ namespace Microsoft.FancyZonesEditor.UITests
{
var deletedLayout = CustomLayouts.CustomLayouts[0].Name;
_session?.ClickEditLayout(deletedLayout);
_session?.ClickDeleteLayout();
_session?.Click(_session.FindByAccessibilityId(AccessibilityId.DeleteLayoutButton));
_session?.ClickConfirmDialog();
_session?.WaitFor(1);
@ -278,7 +278,7 @@ namespace Microsoft.FancyZonesEditor.UITests
{
var deletedLayout = CustomLayouts.CustomLayouts[1].Name;
_session?.ClickEditLayout(deletedLayout);
_session?.ClickDeleteLayout();
_session?.Click(_session.FindByAccessibilityId(AccessibilityId.DeleteLayoutButton));
_session?.ClickCancelDialog();
_session?.WaitFor(1);
@ -321,7 +321,7 @@ namespace Microsoft.FancyZonesEditor.UITests
// verify the default layout is reset to the "default" default
_session?.ClickEditLayout(Constants.TemplateLayoutNames[Constants.TemplateLayouts.PriorityGrid]);
Assert.IsNotNull(_session?.GetHorizontalDefaultButton(true));
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var defaultLayouts = new DefaultLayouts();
@ -356,11 +356,11 @@ namespace Microsoft.FancyZonesEditor.UITests
}
catch
{
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
Assert.Fail("Hotkey not found");
}
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var hotkeys = new LayoutHotkeys();

View File

@ -199,9 +199,9 @@ namespace Microsoft.FancyZonesEditor.UITests
public void OpenEditMode()
{
_session?.ClickEditLayout(Layouts.CustomLayouts[0].Name);
_session?.ClickEditZones();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.EditZonesButton));
Assert.IsNotNull(_session?.FindByName(ElementName.GridLayoutEditor));
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
}
[TestMethod]
@ -209,7 +209,7 @@ namespace Microsoft.FancyZonesEditor.UITests
{
_session?.ClickContextMenuItem(Layouts.CustomLayouts[0].Name, FancyZonesEditorSession.ElementName.EditZones);
Assert.IsNotNull(_session?.FindByName(ElementName.GridLayoutEditor));
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
}
[TestMethod]
@ -217,8 +217,8 @@ namespace Microsoft.FancyZonesEditor.UITests
{
var canvas = Layouts.CustomLayouts.Find(x => x.Type == Constants.CustomLayoutTypeNames[Constants.CustomLayoutType.Canvas]);
_session?.ClickContextMenuItem(canvas.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.ClickAddNewZone();
_session?.ClickSave();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewZoneButton));
_session?.Click(ElementName.Save);
// check the file
var customLayouts = new CustomLayouts();
@ -233,8 +233,8 @@ namespace Microsoft.FancyZonesEditor.UITests
{
var canvas = Layouts.CustomLayouts.Find(x => x.Type == Constants.CustomLayoutTypeNames[Constants.CustomLayoutType.Canvas]);
_session?.ClickContextMenuItem(canvas.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.ClickAddNewZone();
_session?.ClickCancel();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewZoneButton));
_session?.Click(ElementName.Cancel);
// check the file
var customLayouts = new CustomLayouts();
@ -251,7 +251,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(canvas.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.WaitElementDisplayedByName(FancyZonesEditorSession.ElementName.CanvasEditorWindow);
_session?.ClickDeleteZone(1);
_session?.ClickSave();
_session?.Click(ElementName.Save);
// check the file
var customLayouts = new CustomLayouts();
@ -267,7 +267,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var canvas = Layouts.CustomLayouts.Find(x => x.Type == Constants.CustomLayoutTypeNames[Constants.CustomLayoutType.Canvas]);
_session?.ClickContextMenuItem(canvas.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.ClickDeleteZone(1);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var customLayouts = new CustomLayouts();
@ -287,7 +287,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(canvas.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.Drag(_session.GetZone(zoneNumber, FancyZonesEditorSession.ClassName.CanvasZone)!, xOffset, yOffset);
_session?.ClickSave();
_session?.Click(ElementName.Save);
// check the file
var customLayouts = new CustomLayouts();
@ -322,7 +322,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(canvas.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.Drag(_session.GetZone(zoneNumber, FancyZonesEditorSession.ClassName.CanvasZone)!, 100, 100);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var customLayouts = new CustomLayouts();
@ -348,7 +348,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(canvas.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.Drag((WindowsElement)_session.GetZone(zoneNumber, FancyZonesEditorSession.ClassName.CanvasZone)?.FindElementByAccessibilityId(FancyZonesEditorSession.AccessibilityId.TopRightCorner)!, xOffset, yOffset);
_session?.ClickSave();
_session?.Click(ElementName.Save);
// check the file
var customLayouts = new CustomLayouts();
@ -385,7 +385,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(canvas.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.Drag((WindowsElement)_session.GetZone(zoneNumber, FancyZonesEditorSession.ClassName.CanvasZone)?.FindElementByAccessibilityId(FancyZonesEditorSession.AccessibilityId.TopRightCorner)!, xOffset, yOffset);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var customLayouts = new CustomLayouts();
@ -410,7 +410,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(grid.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.GetZone(zoneNumber, FancyZonesEditorSession.ClassName.GridZone)!.Click(); // horizontal split in the middle of the zone
_session?.ClickSave();
_session?.Click(ElementName.Save);
// check the file
var customLayouts = new CustomLayouts();
@ -439,7 +439,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(grid.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.GetZone(zoneNumber, FancyZonesEditorSession.ClassName.GridZone)!.Click(); // horizontal split in the middle of the zone
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var customLayouts = new CustomLayouts();
@ -469,7 +469,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(grid.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.MergeGridZones(1, 2);
_session?.ClickSave();
_session?.Click(ElementName.Save);
// check the file
var customLayouts = new CustomLayouts();
@ -503,7 +503,7 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(grid.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.MergeGridZones(1, 2);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
// check the file
var customLayouts = new CustomLayouts();
@ -539,8 +539,8 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(grid.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.MoveSplitter(0, -100);
_session?.ClickSave();
_session?.ClickSave(); // single click doesn't work after moving a splitter
_session?.Click(ElementName.Save);
_session?.Click(ElementName.Save); // single click doesn't work after moving a splitter
// check the file
var customLayouts = new CustomLayouts();
@ -575,8 +575,8 @@ namespace Microsoft.FancyZonesEditor.UITests
_session?.ClickContextMenuItem(grid.Name, FancyZonesEditorSession.ElementName.EditZones);
_session?.MoveSplitter(0, -100);
_session?.ClickCancel();
_session?.ClickCancel(); // single click doesn't work after moving a splitter
_session?.Click(ElementName.Cancel);
_session?.Click(ElementName.Cancel); // single click doesn't work after moving a splitter
// check the file
var customLayouts = new CustomLayouts();

View File

@ -316,7 +316,7 @@ namespace Microsoft.FancyZonesEditor.UITests
{
try
{
_session?.ClickCancel(); // in case if test has failed
_session?.Click(ElementName.Cancel); // in case if test has failed
}
catch
{
@ -367,7 +367,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.Fail("Hotkey is missed");
}
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(hotkeyComboBox); // let the dialog window close
}
}
@ -392,7 +392,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreEqual(key, hotkeyComboBox.Text);
// verify the file
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(hotkeyComboBox); // let the dialog window close
var hotkeys = new LayoutHotkeys();
var actualData = hotkeys.Read(hotkeys.File);
@ -436,7 +436,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreEqual(key, hotkeyComboBox.Text);
// verify the file
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(hotkeyComboBox); // let the dialog window close
var hotkeys = new LayoutHotkeys();
var actualData = hotkeys.Read(hotkeys.File);
@ -476,7 +476,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.IsNotNull(popup);
_session?.Click(popup.FindElementByName($"{i}")!);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(hotkeyComboBox); // let the dialog window close
}
@ -505,7 +505,7 @@ namespace Microsoft.FancyZonesEditor.UITests
}
_session?.Click(popup.FindElementByName($"None")!);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(hotkeyComboBox); // let the dialog window close
}
}
@ -529,7 +529,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreEqual(None, hotkeyComboBox.Text);
// verify the file
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(hotkeyComboBox); // let the dialog window close
var hotkeys = new LayoutHotkeys();
var actualData = hotkeys.Read(hotkeys.File);
@ -572,7 +572,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreEqual(None, hotkeyComboBox.Text);
// verify the file
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(hotkeyComboBox); // let the dialog window close
var hotkeys = new LayoutHotkeys();
var actualData = hotkeys.Read(hotkeys.File);

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using FancyZonesEditorCommon.Data;
using Microsoft.FancyZonesEditor.UnitTests.Utils;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static Microsoft.FancyZonesEditor.UnitTests.Utils.FancyZonesEditorSession;
namespace Microsoft.FancyZonesEditor.UITests
{
@ -180,7 +181,7 @@ namespace Microsoft.FancyZonesEditor.UITests
[TestMethod]
public void OpenNewLayoutDialog() // verify the new layout dialog is opened
{
_session?.ClickCreateNewLayout();
_session?.Click(_session?.FindByAccessibilityId(AccessibilityId.NewLayoutButton));
Assert.IsNotNull(_session?.FindByName("Choose layout type")); // check the pane header
}

View File

@ -220,7 +220,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var expected = Layouts.LayoutTemplates.Find(x => x.Type == Constants.TemplateLayoutTypes[key]).ZoneCount;
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
}
}
@ -239,7 +239,7 @@ namespace Microsoft.FancyZonesEditor.UITests
slider.SendKeys(Keys.Left);
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -261,7 +261,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.IsNotNull(slider);
slider.SendKeys(Keys.Left);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -288,7 +288,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var expected = Layouts.LayoutTemplates.Find(x => x.Type == Constants.TemplateLayoutTypes[key]).SensitivityRadius;
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
}
}
@ -308,7 +308,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var expected = value + 1; // one step right
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -329,7 +329,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var slider = _session?.FindByAccessibilityId(AccessibilityId.SensitivitySlider);
Assert.IsNotNull(slider);
slider.SendKeys(Keys.Right);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -361,7 +361,7 @@ namespace Microsoft.FancyZonesEditor.UITests
var expected = Layouts.LayoutTemplates.Find(x => x.Type == Constants.TemplateLayoutTypes[key]).Spacing;
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
}
}
@ -379,7 +379,7 @@ namespace Microsoft.FancyZonesEditor.UITests
slider.SendKeys(Keys.Right);
Assert.AreEqual($"{expected}", slider.Text);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -402,7 +402,7 @@ namespace Microsoft.FancyZonesEditor.UITests
slider.SendKeys(Keys.Right);
Assert.AreEqual($"{expected + 1}", slider.Text);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(slider); // let the dialog window close
// verify the file
@ -426,7 +426,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreEqual(expected, toggle.Selected);
Assert.AreEqual(expected, _session?.FindByAccessibilityId(AccessibilityId.SpacingSlider)?.Enabled);
_session?.ClickSave();
_session?.Click(ElementName.Save);
_session?.WaitUntilHidden(toggle); // let the dialog window close
// verify the file
@ -450,7 +450,7 @@ namespace Microsoft.FancyZonesEditor.UITests
Assert.AreNotEqual(expected, toggle.Selected);
Assert.AreNotEqual(expected, _session?.FindByAccessibilityId(AccessibilityId.SpacingSlider)?.Enabled);
_session?.ClickCancel();
_session?.Click(ElementName.Cancel);
_session?.WaitUntilHidden(toggle); // let the dialog window close
// verify the file

View File

@ -268,11 +268,15 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
return null;
}
public void ClickCreateNewLayout()
public void Click(WindowsElement? element)
{
var button = FindByAccessibilityId(AccessibilityId.NewLayoutButton);
Assert.IsNotNull(button, "Create new layout button not found");
button.Click();
Assert.IsNotNull(element);
element.Click();
}
public void Click(string name)
{
Click(Session.FindElementByName(name));
}
public void ClickEditLayout(string layoutName)
@ -295,12 +299,6 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
}
}
public void ClickEditZones()
{
var button = FindByAccessibilityId(AccessibilityId.EditZonesButton);
button?.Click();
}
public void RightClickLayout(string layoutName)
{
var layout = GetLayout(layoutName);
@ -315,20 +313,6 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
Click(monitor);
}
public void ClickSave()
{
var button = Session.FindElementByName(ElementName.Save);
Assert.IsNotNull(button, "No Save button");
button.Click();
}
public void ClickCancel()
{
var button = Session.FindElementByName(ElementName.Cancel);
Assert.IsNotNull(button, "No Cancel button");
button.Click();
}
public void ClickCopyLayout()
{
WindowsElement? button = null;
@ -352,12 +336,6 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
button.Click();
}
public void ClickDeleteLayout()
{
WindowsElement button = Session.FindElementByAccessibilityId(AccessibilityId.DeleteLayoutButton);
button.Click();
}
public void ClickConfirm()
{
WaitElementDisplayedById(AccessibilityId.PrimaryButton);
@ -386,13 +364,6 @@ namespace Microsoft.FancyZonesEditor.UnitTests.Utils
Click(menu.FindElementByName(menuItem));
}
public void ClickAddNewZone()
{
var button = FindByAccessibilityId(AccessibilityId.NewZoneButton);
Assert.IsNotNull(button);
button.Click();
}
public void ClickDeleteZone(int zoneNumber)
{
var zone = GetZone(zoneNumber, ClassName.CanvasZone);