Update Standard Mode Calculator UI Tests (#788)
Additional Standard mode UI Tests added.
This commit is contained in:
parent
d196909246
commit
d8fedaffde
6
.gitignore
vendored
6
.gitignore
vendored
@ -293,4 +293,8 @@ src/GraphControl/GraphingImplOverrides.props
|
||||
src/CalcViewModel/DataLoaders/DataLoaderConstants.h
|
||||
!/build/config/TRexDefs/**
|
||||
!src/Calculator/TemporaryKey.pfx
|
||||
!src/CalculatorUnitTests/CalculatorUnitTests_TemporaryKey.pfx
|
||||
!src/CalculatorUnitTests/CalculatorUnitTests_TemporaryKey.pfx
|
||||
!src/x64
|
||||
!src/x86
|
||||
!src/out
|
||||
!src/ARM
|
70
src/CalculatorUITestFramework/CalculatorApp.cs
Normal file
70
src/CalculatorUITestFramework/CalculatorApp.cs
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains the UI automation objects and helper methods available when the Calculator is in any mode.
|
||||
/// </summary>
|
||||
public static class CalculatorApp
|
||||
{
|
||||
public static WindowsElement Window => session.FindElementByClassName("Windows.UI.Core.CoreWindow");
|
||||
|
||||
internal static WindowsElement Header => session.TryFindElementByAccessibilityId("Header");
|
||||
|
||||
private static WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
private static WindowsElement AppName => session.TryFindElementByAccessibilityId("AppName");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text from the Header
|
||||
/// </summary>
|
||||
/// <returns>The string shown in the UI.</returns>
|
||||
public static string GetCalculatorHeaderText()
|
||||
{
|
||||
return Header.Text;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Clicks the AppName element on Windows Calculator to ensure that the app has focus
|
||||
///// </summary>
|
||||
public static void EnsureCalculatorHasFocus()
|
||||
{
|
||||
AppName.Click();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the the Dock Panel for the History and Memory lists is not displayed, resize the window
|
||||
/// Two attempts are made, the the lable is not found a "not found" exception is thrown
|
||||
/// </summary>
|
||||
public static void ResizeWindowToDisplayMemoryHistoryDockPanel()
|
||||
{
|
||||
// Put the calculator in the upper left region of the screen
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Position = new Point(8, 8);
|
||||
GrowWindowToShowDock(WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increases the size of the window until Dock Panel for the History/Memory panel is visible
|
||||
/// </summary>
|
||||
private static void GrowWindowToShowDock(int width)
|
||||
{
|
||||
if (width > 2100)
|
||||
{
|
||||
throw new NotFoundException("Could not the Dock Panel for the History and Memory lists");
|
||||
}
|
||||
|
||||
if (!session.PageSource.Contains("DockPanel"))
|
||||
{
|
||||
var height = WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Height;
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Size = new Size(width, height);
|
||||
//give window time to render new size
|
||||
System.Threading.Thread.Sleep(10);
|
||||
GrowWindowToShowDock(width + 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
65
src/CalculatorUITestFramework/CalculatorResults.cs
Normal file
65
src/CalculatorUITestFramework/CalculatorResults.cs
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
public class CalculatorResults
|
||||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
private WindowsElement CalculatorAlwaysOnTopResults => this.session.TryFindElementByAccessibilityId("CalculatorAlwaysOnTopResults");
|
||||
private WindowsElement CalculatorResult => this.session.TryFindElementByAccessibilityId("CalculatorResults");
|
||||
private WindowsElement CalculatorExpression => this.session.TryFindElementByAccessibilityId("CalculatorExpression");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text from the display control in AoT mode and removes the narrator text that is not displayed in the UI.
|
||||
/// </summary>
|
||||
/// <returns>The string shown in the UI.</returns>
|
||||
public string GetAoTCalculatorResultText()
|
||||
{
|
||||
return this.CalculatorAlwaysOnTopResults.Text.Replace("Display is", string.Empty).Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text from the display control and removes the narrator text that is not displayed in the UI.
|
||||
/// </summary>
|
||||
/// <returns>The string shown in the UI.</returns>
|
||||
public string GetCalculatorResultText()
|
||||
{
|
||||
return this.CalculatorResult.Text.Replace("Display is", string.Empty).Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text from the Calculator Expression control and removes narrator text that is not displayed in the UI.
|
||||
/// </summary>
|
||||
/// <returns>The string shown in the UI.</returns>
|
||||
public string GetCalculatorExpressionText()
|
||||
{
|
||||
return this.CalculatorExpression.Text.Replace("Expression is", string.Empty).Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that CalculatorResult is not null
|
||||
/// </summary>
|
||||
/// <returns>The string shown in the UI.</returns>
|
||||
public void IsResultsDisplayPresent()
|
||||
{
|
||||
Assert.IsNotNull(this.CalculatorResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that Calculator Expression is clear
|
||||
/// </summary>
|
||||
/// <returns>The string shown in the UI.</returns>
|
||||
public void IsResultsExpressionClear()
|
||||
{
|
||||
string source = WinAppDriver.Instance.CalculatorSession.PageSource;
|
||||
if (source.Contains("CalculatorExpression"))
|
||||
{
|
||||
throw new Exception("The Calculator Expression is not clear");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +1,34 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
public class HistoryPanel
|
||||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
public WindowsElement HistoryLabel => this.session.TryFindElementByAccessibilityId("HistoryLabel");
|
||||
public WindowsElement HistoryListView => this.session.TryFindElementByAccessibilityId("HistoryListView");
|
||||
public WindowsElement HistoryButton => this.session.TryFindElementByAccessibilityId("HistoryButton");
|
||||
public WindowsElement ListViewItem => this.session.FindElementByClassName("ListViewItem");
|
||||
public WindowsElement ClearHistoryButton => this.session.TryFindElementByAccessibilityId("ClearHistory");
|
||||
public WindowsElement HistoryEmptyLabel => this.session.TryFindElementByAccessibilityId("HistoryEmpty");
|
||||
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
private WindowsElement HistoryLabel => this.session.TryFindElementByAccessibilityId("HistoryLabel");
|
||||
private WindowsElement HistoryListView => this.session.TryFindElementByAccessibilityId("HistoryListView");
|
||||
private WindowsElement HistoryFlyout => this.session.TryFindElementByAccessibilityId("HistoryFlyout");
|
||||
|
||||
/// <summary>
|
||||
/// Opens the History Pane by clicking the History pivot label.
|
||||
/// </summary>
|
||||
public void OpenHistoryPanel()
|
||||
{
|
||||
this.ResizeWindowToDisplayHistoryLabel();
|
||||
this.HistoryLabel.Click();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all of the history items listed in the History Pane.
|
||||
@ -24,8 +36,7 @@ public class HistoryPanel
|
||||
/// <returns>A readonly collection of history items.</returns>
|
||||
public ReadOnlyCollection<AppiumWebElement> GetAllHistoryListViewItems()
|
||||
{
|
||||
this.HistoryLabel.Click();
|
||||
this.HistoryListView.WaitForDisplayed();
|
||||
OpenHistoryPanel();
|
||||
return this.HistoryListView.FindElementsByClassName("ListViewItem");
|
||||
}
|
||||
|
||||
@ -34,21 +45,96 @@ public ReadOnlyCollection<AppiumWebElement> GetAllHistoryListViewItems()
|
||||
/// </summary>
|
||||
public void ClearHistory()
|
||||
{
|
||||
this.HistoryLabel.Click();
|
||||
|
||||
try
|
||||
this.HistoryLabel.Click();
|
||||
string source = this.session.PageSource;
|
||||
if (source.Contains("ClearHistory"))
|
||||
{
|
||||
this.ClearHistoryButton.Click();
|
||||
}
|
||||
catch(WebDriverException ex)
|
||||
{
|
||||
if (ex.Message.Contains("element could not be located"))
|
||||
{
|
||||
Assert.IsNotNull(this.HistoryEmptyLabel);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw;
|
||||
/// <summary>
|
||||
/// If the History label is not displayed, resize the window
|
||||
/// Two attempts are made; the label is not found a "not found" exception is thrown
|
||||
/// </summary>
|
||||
public void ResizeWindowToDisplayHistoryLabel()
|
||||
{
|
||||
// Put the calculator in the upper left region of the screen
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Position = new Point(8, 8);
|
||||
GrowWindowToShowHistoryLabel(WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Width);
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// If the History button is not displayed, resize the window
|
||||
///// </summary>
|
||||
public void ResizeWindowToDisplayHistoryButton()
|
||||
{
|
||||
// Put the calculator in the upper left region of the screen
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Position = new Point(8, 8);
|
||||
ShrinkWindowToShowHistoryButton(WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the History Flyout.
|
||||
/// </summary>
|
||||
public void OpenHistoryFlyout()
|
||||
{
|
||||
this.ResizeWindowToDisplayHistoryButton();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Control + "h" + Keys.Control);
|
||||
Actions moveToHistoryFlyout = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
moveToHistoryFlyout.MoveToElement(HistoryFlyout);
|
||||
moveToHistoryFlyout.Perform();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all of the History items listed in the History Flyout.
|
||||
/// </summary>
|
||||
/// <returns> A read only collection of History items.</returns>
|
||||
public ReadOnlyCollection<AppiumWebElement> GetAllHistoryFlyoutListViewItems()
|
||||
{
|
||||
OpenHistoryFlyout();
|
||||
return this.HistoryListView.FindElementsByClassName("ListViewItem");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increases the size of the window until History label for the History panel is visible
|
||||
/// </summary>
|
||||
private void GrowWindowToShowHistoryLabel(int width)
|
||||
{
|
||||
if (width > 2100)
|
||||
{
|
||||
throw new NotFoundException("Could not the History Label");
|
||||
}
|
||||
|
||||
if (!this.session.PageSource.Contains("HistoryLabel"))
|
||||
{
|
||||
var height = WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Height;
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Size = new Size(width, height);
|
||||
//give window time to render new size
|
||||
System.Threading.Thread.Sleep(10);
|
||||
GrowWindowToShowHistoryLabel(width + 100);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decreases the size of the window until History button is visible
|
||||
/// </summary>
|
||||
private void ShrinkWindowToShowHistoryButton(int width)
|
||||
{
|
||||
if (width < 200)
|
||||
{
|
||||
throw new NotFoundException("Could not find the History Button");
|
||||
}
|
||||
|
||||
if (!this.session.PageSource.Contains("HistoryButton"))
|
||||
{
|
||||
var height = WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Height;
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Size = new Size(width, height);
|
||||
//give window time to render new size
|
||||
System.Threading.Thread.Sleep(10);
|
||||
ShrinkWindowToShowHistoryButton(width - 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,40 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
public class MemoryPanel
|
||||
{
|
||||
public WindowsElement NumberpadMCButton => this.session.TryFindElementByAccessibilityId("ClearMemoryButton");
|
||||
public WindowsElement NumberpadMRButton => this.session.TryFindElementByAccessibilityId("MemRecall");
|
||||
public WindowsElement NumberpadMPlusButton => this.session.TryFindElementByAccessibilityId("MemPlus");
|
||||
public WindowsElement NumberpadMMinusButton => this.session.TryFindElementByAccessibilityId("MemMinus");
|
||||
public WindowsElement NumberpadMSButton => this.session.TryFindElementByAccessibilityId("memButton");
|
||||
public WindowsElement MemoryFlyoutButton => this.session.TryFindElementByAccessibilityId("MemoryButton");
|
||||
public WindowsElement PanelClearMemoryButton => this.session.TryFindElementByAccessibilityId("ClearMemory");
|
||||
public WindowsElement ListViewItem => this.session.FindElementByClassName("ListViewItem");
|
||||
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
public WindowsElement MemoryClear => this.session.TryFindElementByAccessibilityId("ClearMemoryButton");
|
||||
public WindowsElement MemRecall => this.session.TryFindElementByAccessibilityId("MemRecall");
|
||||
public WindowsElement MemPlus => this.session.TryFindElementByAccessibilityId("MemPlus");
|
||||
public WindowsElement MemMinus => this.session.TryFindElementByAccessibilityId("MemMinus");
|
||||
public WindowsElement MemButton => this.session.TryFindElementByAccessibilityId("memButton");
|
||||
public WindowsElement MemoryPane => this.session.TryFindElementByAccessibilityId("MemoryPanel");
|
||||
public WindowsElement MemoryLabel => this.session.TryFindElementByAccessibilityId("MemoryLabel");
|
||||
public WindowsElement MemoryListView => this.session.TryFindElementByAccessibilityId("MemoryListView");
|
||||
public WindowsElement MemoryPaneEmptyLabel => this.session.TryFindElementByAccessibilityId("MemoryPaneEmpty");
|
||||
private WindowsElement MemoryPane => this.session.TryFindElementByAccessibilityId("MemoryPanel");
|
||||
private WindowsElement MemoryLabel => this.session.TryFindElementByAccessibilityId("MemoryLabel");
|
||||
private WindowsElement MemoryListView => this.session.TryFindElementByAccessibilityId("MemoryListView");
|
||||
private WindowsElement MemoryPaneEmptyLabel => this.session.TryFindElementByAccessibilityId("MemoryPaneEmpty");
|
||||
private WindowsElement MemoryFlyout => this.session.TryFindElementByAccessibilityId("MemoryFlyout");
|
||||
|
||||
/// <summary>
|
||||
/// Opens the Memory Pane by clicking the Memory pivot label.
|
||||
/// </summary>
|
||||
public void OpenMemoryPanel()
|
||||
{
|
||||
this.ResizeWindowToDisplayMemoryLabel();
|
||||
this.MemoryLabel.Click();
|
||||
this.MemoryPane.WaitForDisplayed();
|
||||
}
|
||||
@ -38,5 +48,119 @@ public ReadOnlyCollection<AppiumWebElement> GetAllMemoryListViewItems()
|
||||
OpenMemoryPanel();
|
||||
return this.MemoryListView.FindElementsByClassName("ListViewItem");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the Memory Panel and clicks the delete button if it is visible
|
||||
/// </summary>
|
||||
public void ClearMemoryPanel()
|
||||
{
|
||||
this.MemoryLabel.Click();
|
||||
|
||||
try
|
||||
{
|
||||
if (this.session.PageSource.Contains("ClearMemoryButton"))
|
||||
{
|
||||
this.PanelClearMemoryButton.Click();
|
||||
}
|
||||
}
|
||||
catch (WebDriverException ex)
|
||||
{
|
||||
if (ex.Message.Contains("element could not be located"))
|
||||
{
|
||||
Assert.IsNotNull(this.MemoryPaneEmptyLabel);
|
||||
return;
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the Memory label is not displayed, resize the window
|
||||
/// Two attempts are made, the the lable is not found a "not found" exception is thrown
|
||||
/// </summary>
|
||||
public void ResizeWindowToDisplayMemoryLabel()
|
||||
{
|
||||
// Put the calculator in the upper left region of the screen
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Position = new Point(8, 8);
|
||||
GrowWindowToShowMemoryLabel(WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the Memory button is not displayed, resize the window
|
||||
/// </summary>
|
||||
public void ResizeWindowToDisplayMemoryButton()
|
||||
{
|
||||
// Put the calculator in the upper left region of the screen
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Position = new Point(8, 8);
|
||||
ShrinkWindowToShowMemoryButton(WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Width);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the Memory Flyout.
|
||||
/// </summary>
|
||||
public void OpenMemoryFlyout()
|
||||
{
|
||||
this.ResizeWindowToDisplayMemoryButton();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
Actions moveToMemoryButton = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
moveToMemoryButton.MoveToElement(MemoryFlyoutButton);
|
||||
moveToMemoryButton.Perform();
|
||||
CalculatorApp.Window.SendKeys(Keys.Alt + "m" + Keys.Alt);
|
||||
Actions moveToMemoryFlyout = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
moveToMemoryFlyout.MoveToElement(MemoryFlyout);
|
||||
moveToMemoryFlyout.Perform();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all of the memory items listed in the Memory Flyout.
|
||||
/// </summary>
|
||||
/// <returns> A read only collection of memory items.</returns>
|
||||
public ReadOnlyCollection<AppiumWebElement> GetAllMemoryFlyoutListViewItems()
|
||||
{
|
||||
OpenMemoryFlyout();
|
||||
return this.MemoryListView.FindElementsByClassName("ListViewItem");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increases the size of the window until Memory label for the Memory panel is visible
|
||||
/// </summary>
|
||||
private void GrowWindowToShowMemoryLabel(int width)
|
||||
{
|
||||
if (width > 2100)
|
||||
{
|
||||
throw new NotFoundException("Could not the Memory Label");
|
||||
}
|
||||
|
||||
if (!this.session.PageSource.Contains("MemoryLabel"))
|
||||
{
|
||||
var height = WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Height;
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Size = new Size(width, height);
|
||||
//give window time to render new size
|
||||
System.Threading.Thread.Sleep(10);
|
||||
GrowWindowToShowMemoryLabel(width + 100);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decreases the size of the window until Memory button is visible
|
||||
/// </summary>
|
||||
private void ShrinkWindowToShowMemoryButton(int width)
|
||||
{
|
||||
if (width < 200)
|
||||
{
|
||||
throw new NotFoundException("Could not find the Memory Button");
|
||||
}
|
||||
|
||||
//Page source contains differnt memory button types, using hotkey info is for this specific memory button
|
||||
if (!this.session.PageSource.Contains("Alt, M"))
|
||||
{
|
||||
var height = WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Height;
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Size = new Size(width, height);
|
||||
//give window time to render new size
|
||||
System.Threading.Thread.Sleep(10);
|
||||
ShrinkWindowToShowMemoryButton(width - 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,14 @@ public enum CalculatorMode
|
||||
Pressure,
|
||||
Angle
|
||||
}
|
||||
|
||||
public class NavigationMenu
|
||||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
|
||||
public WindowsElement NavigationMenuButton => this.session.TryFindElementByAccessibilityId("TogglePaneButton");
|
||||
public WindowsElement NavigationMenuPane => this.session.TryFindElementByClassName("SplitViewPane");
|
||||
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
|
||||
/// <summary>
|
||||
/// Changes the mode using the navigation menu in the UI
|
||||
/// </summary>
|
||||
|
@ -8,7 +8,6 @@ namespace CalculatorUITestFramework
|
||||
{
|
||||
public class NumberPad
|
||||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
public WindowsElement Num0Button => this.session.TryFindElementByAccessibilityId("num0Button");
|
||||
public WindowsElement Num1Button => this.session.TryFindElementByAccessibilityId("num1Button");
|
||||
public WindowsElement Num2Button => this.session.TryFindElementByAccessibilityId("num2Button");
|
||||
@ -22,6 +21,8 @@ public class NumberPad
|
||||
public WindowsElement DecimalButton => this.session.TryFindElementByAccessibilityId("decimalSeparatorButton");
|
||||
public WindowsElement NegateButton => this.session.TryFindElementByAccessibilityId("negateButton");
|
||||
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
|
||||
/// <summary>
|
||||
/// Translates a number into the Calculator button clicks.
|
||||
/// </summary>
|
||||
|
164
src/CalculatorUITestFramework/StandardAoTCalculatorPage.cs
Normal file
164
src/CalculatorUITestFramework/StandardAoTCalculatorPage.cs
Normal file
@ -0,0 +1,164 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains the UI automation objects and helper methods available when the Calculator is in Standard / AoT Mode.
|
||||
/// </summary>
|
||||
public class StandardAoTCalculatorPage
|
||||
{
|
||||
public StandardOperatorsPanel StandardOperators = new StandardOperatorsPanel();
|
||||
public NavigationMenu NavigationMenu = new NavigationMenu();
|
||||
public WindowsElement EnterAlwaysOnTopButton => this.session.TryFindElementByAccessibilityId("NormalAlwaysOnTopButton");
|
||||
public WindowsElement ExitAlwaysOnTopButton => this.session.TryFindElementByAccessibilityId("ExitAlwaysOnTopButton");
|
||||
public AppiumWebElement ToolTip => WinAppDriver.Instance.CalculatorSession.FindElementByClassName("ToolTip").FindElementByClassName("TextBlock");
|
||||
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
|
||||
///// <summary>
|
||||
///// Navigates from AoT(Keep on top) to Standard
|
||||
///// </summary>
|
||||
public void NavigateToStandardMode()
|
||||
{
|
||||
string source = this.session.PageSource;
|
||||
if (source.Contains("ExitAlwaysOnTopButton"))
|
||||
{
|
||||
this.ExitAlwaysOnTopButton.Click();
|
||||
Assert.AreEqual("Standard", CalculatorApp.GetCalculatorHeaderText());
|
||||
}
|
||||
else
|
||||
{
|
||||
source = this.session.PageSource;
|
||||
if (source.Contains("NormalAlwaysOnTopButton"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotFoundException("Could not find the 'Keep on top' button");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Ensures the calculator is in AoT(Keep on top) mode, and verifies that the AoT mode through the absence of the header
|
||||
///// </summary>
|
||||
public void NavigateToStandardAoTMode()
|
||||
{
|
||||
string source = this.session.PageSource;
|
||||
if (source.Contains("NormalAlwaysOnTopButton"))
|
||||
{
|
||||
this.EnterAlwaysOnTopButton.Click();
|
||||
this.ExitAlwaysOnTopButton.WaitForDisplayed();
|
||||
source = WinAppDriver.Instance.CalculatorSession.PageSource;
|
||||
if (source.Contains("Header"))
|
||||
{
|
||||
throw new NotFoundException("Failed to enter 'Keep on top' mode; In AoT mode, Calculator does not have header");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Gets the AoT ToolTip text
|
||||
///// </summary>
|
||||
public string GetAoTToolTipText()
|
||||
{
|
||||
string source = this.session.PageSource;
|
||||
if ((source.Contains("Keep on top")) || (source.Contains("Back to full view")))
|
||||
{
|
||||
if (source.Contains("Keep on top"))
|
||||
{
|
||||
Actions moveToAoTButton = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
moveToAoTButton.MoveToElement(EnterAlwaysOnTopButton);
|
||||
moveToAoTButton.Perform();
|
||||
}
|
||||
else
|
||||
{
|
||||
Actions moveToBackToFullViewVButton = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
moveToBackToFullViewVButton.MoveToElement(ExitAlwaysOnTopButton);
|
||||
moveToBackToFullViewVButton.Perform();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotFoundException("Could not find 'Keep on top' button or 'Back to full view' button");
|
||||
}
|
||||
var ToolTipText = ToolTip.Text.ToString();
|
||||
return ToolTipText;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Checks in AoT (Keep on top) button is present
|
||||
///// </summary>
|
||||
public string GetAoTPresence()
|
||||
{
|
||||
bool AoTPresent;
|
||||
string source = this.session.PageSource;
|
||||
if (source.Contains("Keep on top"))
|
||||
{
|
||||
AoTPresent = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AoTPresent = false;
|
||||
}
|
||||
return AoTPresent.ToString();
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Checks Standard calculator to see if it's in AoT (Keep on top)
|
||||
///// </summary>
|
||||
public string AoTModeCheck()
|
||||
{
|
||||
bool InAoTMode;
|
||||
string source = this.session.PageSource;
|
||||
if ((source.Contains("Keep on top")) && (source.Contains("Header")))
|
||||
{
|
||||
InAoTMode = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InAoTMode = true;
|
||||
}
|
||||
return InAoTMode.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the Invert button is not displayed, resize the window
|
||||
/// Two attempts are made, the the button is not found a "not found" exception is thrown
|
||||
/// </summary>
|
||||
public void ResizeAoTWindowToDisplayInvertButton()
|
||||
{
|
||||
// Put the calculator in the upper left region of the screen
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Position = new Point(8, 8);
|
||||
GrowWindowToShowInvertButton(WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increases the size of the window until History label for the History panel is visible
|
||||
/// </summary>
|
||||
private void GrowWindowToShowInvertButton(int height)
|
||||
{
|
||||
if (height > 1000)
|
||||
{
|
||||
throw new NotFoundException("Could not find the Invert Button");
|
||||
}
|
||||
|
||||
if (!this.session.PageSource.Contains("invertButton"))
|
||||
{
|
||||
var width = WinAppDriver.Instance.CalculatorSession.Manage().Window.Size.Width;
|
||||
WinAppDriver.Instance.CalculatorSession.Manage().Window.Size = new Size(width, height);
|
||||
//give window time to render new size
|
||||
System.Threading.Thread.Sleep(10);
|
||||
GrowWindowToShowInvertButton(width + 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
@ -11,20 +10,23 @@ namespace CalculatorUITestFramework
|
||||
/// </summary>
|
||||
public class StandardCalculatorPage
|
||||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
public StandardOperatorsPanel StandardOperators = new StandardOperatorsPanel();
|
||||
public MemoryPanel MemoryPanel = new MemoryPanel();
|
||||
public HistoryPanel HistoryPanel = new HistoryPanel();
|
||||
public NavigationMenu NavigationMenu = new NavigationMenu();
|
||||
public WindowsElement Header => this.session.TryFindElementByAccessibilityId("Header");
|
||||
public StandardAoTCalculatorPage StandardAoTCalculatorPage = new StandardAoTCalculatorPage();
|
||||
public CalculatorResults CalculatorResults = new CalculatorResults();
|
||||
|
||||
public WindowsElement CalculatorResult => this.session.TryFindElementByAccessibilityId("CalculatorResults");
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
|
||||
/// <summary>
|
||||
/// Navigates the caclulator to Standard mode and ensures that it is in standard mode
|
||||
/// </summary>
|
||||
public void NavigateToStandardCalculator()
|
||||
{
|
||||
// Ensure that calculator is in standard mode
|
||||
this.NavigationMenu.ChangeCalculatorMode(CalculatorMode.StandardCalculator);
|
||||
Assert.IsNotNull(CalculatorResult);
|
||||
this.CalculatorResults.IsResultsDisplayPresent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -32,18 +34,47 @@ public void NavigateToStandardCalculator()
|
||||
/// </summary>
|
||||
public void ClearAll()
|
||||
{
|
||||
this.StandardAoTCalculatorPage.NavigateToStandardMode();
|
||||
this.MemoryPanel.ResizeWindowToDisplayMemoryLabel();
|
||||
this.StandardOperators.ClearButton.Click();
|
||||
this.MemoryPanel.MemoryClear.Click();
|
||||
this.MemoryPanel.NumberpadMCButton.Click();
|
||||
this.HistoryPanel.ClearHistory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the text from the display control and removes the narrator text that is not displayed in the UI.
|
||||
/// </summary>
|
||||
/// <returns>The string shown in the UI.</returns>
|
||||
public string GetCalculatorResultText()
|
||||
///// <summary>
|
||||
///// Ensures that the calculator result text is zero; if not, clears all
|
||||
///// </summary>
|
||||
public void EnsureCalculatorResultTextIsZero()
|
||||
{
|
||||
return this.CalculatorResult.Text.Replace("Display is", string.Empty).Trim();
|
||||
if ("0" != this.CalculatorResults.GetCalculatorResultText())
|
||||
{
|
||||
this.ClearAll();
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Ensures that the calculator is in Standard Mode
|
||||
///// </summary>
|
||||
public void EnsureCalculatorIsInStandardMode()
|
||||
{
|
||||
string source = WinAppDriver.Instance.CalculatorSession.PageSource;
|
||||
if (source.Contains("Header"))
|
||||
{
|
||||
string header = CalculatorApp.Header.Text;
|
||||
if (header == "Standard")
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.NavigateToStandardCalculator();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.StandardAoTCalculatorPage.NavigateToStandardMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
@ -27,5 +26,7 @@ public class StandardOperatorsPanel
|
||||
public WindowsElement ClearEntryButton => this.session.TryFindElementByAccessibilityId("clearEntryButton");
|
||||
public WindowsElement ClearButton => this.session.TryFindElementByAccessibilityId("clearButton");
|
||||
public WindowsElement BackSpaceButton => this.session.TryFindElementByAccessibilityId("backSpaceButton");
|
||||
public WindowsElement NegateButton => this.session.TryFindElementByAccessibilityId("negateButton");
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ public static WinAppDriver Instance
|
||||
|
||||
public WindowsDriver<WindowsElement> CalculatorSession { get; private set; }
|
||||
|
||||
|
||||
private WinAppDriver()
|
||||
{
|
||||
}
|
||||
@ -88,6 +87,5 @@ public void TearDownCalculatorSession()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
166
src/CalculatorUITests/HistoryFunctionalTests.cs
Normal file
166
src/CalculatorUITests/HistoryFunctionalTests.cs
Normal file
@ -0,0 +1,166 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using CalculatorUITestFramework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
using System;
|
||||
|
||||
namespace CalculatorUITests
|
||||
{
|
||||
[TestClass]
|
||||
public class HistoryFunctionalTests
|
||||
{
|
||||
private static StandardCalculatorPage page = new StandardCalculatorPage();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the WinAppDriver web driver session.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
// Create session to launch a Calculator window
|
||||
WinAppDriver.Instance.SetupCalculatorSession(context);
|
||||
|
||||
// Ensure that calculator is in standard mode
|
||||
page.NavigateToStandardCalculator();
|
||||
|
||||
// Ensure that calculator window is large enough to display the memory/history panel; a good size for most tests
|
||||
page.MemoryPanel.ResizeWindowToDisplayMemoryLabel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the app and WinAppDriver web driver session.
|
||||
/// </summary>
|
||||
[ClassCleanup]
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
// Tear down Calculator session.
|
||||
WinAppDriver.Instance.TearDownCalculatorSession();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the calculator is in a cleared state
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public void TestInit()
|
||||
{
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
page.EnsureCalculatorIsInStandardMode();
|
||||
page.EnsureCalculatorResultTextIsZero();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
page.EnsureCalculatorIsInStandardMode();
|
||||
page.ClearAll();
|
||||
}
|
||||
|
||||
#region Standard History Tests
|
||||
|
||||
/// <summary>
|
||||
/// These automated tests (that replace this manual test case) verify using
|
||||
/// history related button/keyboard actions in the History Panel,
|
||||
/// and in the History flyout. The History button is verified in the automated test MouseInput_HistoryButtons().
|
||||
/// To-Do: Currently, an empty history panel on initial launch cannot be verified through automation.
|
||||
/// The automation cannot see the Windows element "HistoryEmpty." This should be automated once the issue is resolved.
|
||||
/// </summary>
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void StandardHistory_Panel()
|
||||
{
|
||||
|
||||
//Verify selecting history items form the history panel, and clearing the history panel
|
||||
page.HistoryPanel.OpenHistoryPanel();
|
||||
|
||||
page.StandardOperators.NumberPad.Input(-3);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(-2.6);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
page.StandardOperators.NumberPad.Input(2);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
var historyItems = page.HistoryPanel.GetAllHistoryListViewItems();
|
||||
Assert.IsTrue(historyItems[0].Text.Equals("2 Minus ( 3= Minus (1", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[1].Text.Equals("-3 + -2.6= Minus (5.6", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
|
||||
|
||||
Actions clickHistoryItemsw1 = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
clickHistoryItemsw1.Click(historyItems[1]);
|
||||
clickHistoryItemsw1.Perform();
|
||||
|
||||
Assert.AreEqual("-5.6", page.CalculatorResults.GetCalculatorResultText());
|
||||
Assert.AreEqual("-3 + -2.6=", page.CalculatorResults.GetCalculatorExpressionText());
|
||||
|
||||
Actions clickHistoryItemsw0 = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
clickHistoryItemsw0.Click(historyItems[0]);
|
||||
clickHistoryItemsw0.Perform();
|
||||
|
||||
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
|
||||
|
||||
page.HistoryPanel.ClearHistory();
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("HistoryEmpty"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void StandardHistory_Flyout()
|
||||
{
|
||||
|
||||
//Verify selecting history items form the history flyout, using up/down arrows and [enter] to select history items,
|
||||
// and clearing the history flyout. Additionally, verify history panel and history flyout have same information.
|
||||
|
||||
page.HistoryPanel.OpenHistoryPanel();
|
||||
|
||||
page.StandardOperators.NumberPad.Input(-3);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(-2.6);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
page.StandardOperators.NumberPad.Input(2);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
var historyPanelItems = page.HistoryPanel.GetAllHistoryListViewItems();
|
||||
Assert.IsTrue(historyPanelItems[0].Text.Equals("2 Minus ( 3= Minus (1", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyPanelItems[1].Text.Equals("-3 + -2.6= Minus (5.6", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
|
||||
|
||||
var historyItems = page.HistoryPanel.GetAllHistoryFlyoutListViewItems();
|
||||
Assert.IsTrue(historyItems[0].Text.Equals("2 Minus ( 3= Minus (1", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[1].Text.Equals("-3 + -2.6= Minus (5.6", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
|
||||
|
||||
page.HistoryPanel.ListViewItem.SendKeys(Keys.ArrowDown + Keys.Enter);
|
||||
|
||||
Assert.AreEqual("-5.6", page.CalculatorResults.GetCalculatorResultText());
|
||||
Assert.AreEqual("-3 + -2.6=", page.CalculatorResults.GetCalculatorExpressionText());
|
||||
|
||||
page.HistoryPanel.OpenHistoryFlyout();
|
||||
page.HistoryPanel.ListViewItem.SendKeys(Keys.ArrowDown + Keys.ArrowUp + Keys.Enter);
|
||||
Assert.AreEqual("-1", page.CalculatorResults.GetCalculatorResultText());
|
||||
|
||||
page.HistoryPanel.OpenHistoryFlyout();
|
||||
page.HistoryPanel.ClearHistoryButton.Click();
|
||||
|
||||
page.HistoryPanel.OpenHistoryFlyout();
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("HistoryEmpty"));
|
||||
|
||||
page.HistoryPanel.OpenHistoryPanel();
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("HistoryEmpty"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
138
src/CalculatorUITests/MemoryFunctionalTests.cs
Normal file
138
src/CalculatorUITests/MemoryFunctionalTests.cs
Normal file
@ -0,0 +1,138 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using CalculatorUITestFramework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
using System;
|
||||
|
||||
namespace CalculatorUITests
|
||||
{
|
||||
[TestClass]
|
||||
public class MemoryFunctionalTests
|
||||
{
|
||||
private static StandardCalculatorPage page = new StandardCalculatorPage();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the WinAppDriver web driver session.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[ClassInitialize]
|
||||
public static void ClassInitialize(TestContext context)
|
||||
{
|
||||
// Create session to launch a Calculator window
|
||||
WinAppDriver.Instance.SetupCalculatorSession(context);
|
||||
|
||||
// Ensure that calculator is in standard mode
|
||||
page.NavigateToStandardCalculator();
|
||||
|
||||
// Ensure that calculator window is large enough to display the memory/history panel; a good size for most tests
|
||||
page.MemoryPanel.ResizeWindowToDisplayMemoryLabel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the app and WinAppDriver web driver session.
|
||||
/// </summary>
|
||||
[ClassCleanup]
|
||||
public static void ClassCleanup()
|
||||
{
|
||||
// Tear down Calculator session.
|
||||
WinAppDriver.Instance.TearDownCalculatorSession();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the calculator is in a cleared state
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public void TestInit()
|
||||
{
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
page.EnsureCalculatorIsInStandardMode();
|
||||
page.EnsureCalculatorResultTextIsZero();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
page.EnsureCalculatorIsInStandardMode();
|
||||
page.ClearAll();
|
||||
}
|
||||
#region Standard Memory Tests
|
||||
|
||||
/// <summary>
|
||||
/// These automated tests verify using memory related buttons in the Memory Panel, and in the memory flyout
|
||||
/// Memory control buttons are verified at the end of automated tested in MouseInput_MemoryButtons()
|
||||
/// </summary>
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void StandardMemory_Panel()
|
||||
{
|
||||
//Verify context menu MC, M+, M-, and verify the clear memory button in the Memory panel
|
||||
page.StandardOperators.NumberPad.Num3Button.Click();
|
||||
page.MemoryPanel.NumberpadMSButton.Click();
|
||||
page.MemoryPanel.NumberpadMSButton.Click();
|
||||
page.MemoryPanel.OpenMemoryPanel();
|
||||
|
||||
Actions moveToListView = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
moveToListView.MoveToElement(memoryItems[0]);
|
||||
moveToListView.ContextClick(memoryItems[0]);
|
||||
moveToListView.Perform();
|
||||
CalculatorApp.Window.SendKeys(Keys.ArrowDown + Keys.ArrowDown + Keys.Enter);
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("0", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
moveToListView.Perform();
|
||||
CalculatorApp.Window.SendKeys(Keys.ArrowUp + Keys.ArrowUp + Keys.Enter);
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("3", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
moveToListView.Perform();
|
||||
CalculatorApp.Window.SendKeys(Keys.ArrowDown + Keys.ArrowUp + Keys.Enter);
|
||||
var memoryItems2 = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems2[0].Text.Equals("3", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
page.MemoryPanel.PanelClearMemoryButton.Click();
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("MemoryPaneEmpty"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void StandardMemory_Flyout()
|
||||
{
|
||||
//Verify context menu MC, M+, M-, and ClearMemoryItemButton, and verify the clear memory button in the Memory flyout
|
||||
page.StandardOperators.NumberPad.Num3Button.Click();
|
||||
page.MemoryPanel.NumberpadMSButton.Click();
|
||||
page.MemoryPanel.NumberpadMSButton.Click();
|
||||
|
||||
page.MemoryPanel.OpenMemoryFlyout();
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryFlyoutListViewItems();
|
||||
Actions moveToListView = new Actions(WinAppDriver.Instance.CalculatorSession);
|
||||
moveToListView.MoveToElement(memoryItems[0]);
|
||||
moveToListView.ContextClick(memoryItems[0]);
|
||||
moveToListView.Perform();
|
||||
CalculatorApp.Window.SendKeys(Keys.ArrowDown + Keys.ArrowDown + Keys.Enter);
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("0", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
page.MemoryPanel.OpenMemoryFlyout();
|
||||
moveToListView.Perform();
|
||||
CalculatorApp.Window.SendKeys(Keys.ArrowUp + Keys.ArrowUp + Keys.Enter);
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("3", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
page.MemoryPanel.OpenMemoryFlyout();
|
||||
moveToListView.Perform();
|
||||
CalculatorApp.Window.SendKeys(Keys.ArrowDown + Keys.ArrowUp + Keys.Enter);
|
||||
var memoryItems2 = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems2[0].Text.Equals("3", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
page.MemoryPanel.OpenMemoryFlyout();
|
||||
page.MemoryPanel.PanelClearMemoryButton.Click();
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("MemoryPaneEmpty"));
|
||||
|
||||
page.MemoryPanel.ResizeWindowToDisplayMemoryLabel();
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("MemoryPaneEmpty"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -3,8 +3,8 @@
|
||||
|
||||
using CalculatorUITestFramework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CalculatorUITests
|
||||
{
|
||||
@ -25,6 +25,9 @@ public static void ClassInitialize(TestContext context)
|
||||
|
||||
// Ensure that calculator is in standard mode
|
||||
page.NavigateToStandardCalculator();
|
||||
|
||||
// Ensure that calculator window is large enough to display the memory/history panel; a good size for most tests
|
||||
CalculatorApp.ResizeWindowToDisplayMemoryHistoryDockPanel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -43,286 +46,730 @@ public static void ClassCleanup()
|
||||
[TestInitialize]
|
||||
public void TestInit()
|
||||
{
|
||||
if ("0" != page.GetCalculatorResultText())
|
||||
{
|
||||
page.ClearAll();
|
||||
}
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
page.EnsureCalculatorIsInStandardMode();
|
||||
page.EnsureCalculatorResultTextIsZero();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void TestCleanup()
|
||||
{
|
||||
page.EnsureCalculatorIsInStandardMode();
|
||||
page.ClearAll();
|
||||
}
|
||||
|
||||
#region Smoke Tests
|
||||
#region Basic UI Functionality via Mouse Input Tests
|
||||
|
||||
/// <summary>
|
||||
/// These automated tests verify clicking each of the buttons in the Calculator UI and getting an expected result
|
||||
/// Via mouse input, all basic UI functionality is checked
|
||||
/// </summary>
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void SmokeTest_Add()
|
||||
public void MouseInput_AddSubtractClearClearEntryTwoThree()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(3.5);
|
||||
//Verifies the +, -, CE, C, 2, and 3 button
|
||||
page.StandardOperators.NumberPad.Num2Button.Click();
|
||||
Assert.AreEqual("2", page.CalculatorResults.GetCalculatorResultText()); //verifies 2 button
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(0.25);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("3.75", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void SmokeTest_Add_KeyboardInput()
|
||||
{
|
||||
page.Header.SendKeys("3+3=");
|
||||
Assert.AreEqual("6", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void SmokeTest_Subtract()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(4.3);
|
||||
Assert.AreEqual("2 +", page.CalculatorResults.GetCalculatorExpressionText()); //verifies + button
|
||||
page.StandardOperators.NumberPad.Num2Button.Click();
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(2.6);
|
||||
Assert.AreEqual("4", page.CalculatorResults.GetCalculatorResultText()); //verifies addition
|
||||
Assert.AreEqual("2 + 2 Minus (", page.CalculatorResults.GetCalculatorExpressionText()); //verifies - button
|
||||
page.StandardOperators.NumberPad.Num3Button.Click();
|
||||
Assert.AreEqual("3", page.CalculatorResults.GetCalculatorResultText()); //verifies 3 button
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("1.7", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void SmokeTest_History()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(-3);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(-2.6);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
page.StandardOperators.NumberPad.Input(2);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
page.StandardOperators.NumberPad.Input(1);
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
var historyItems = page.HistoryPanel.GetAllHistoryListViewItems();
|
||||
Assert.IsTrue(historyItems[0].Text.Equals("1 × 3= 3", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[1].Text.Equals("2 Minus ( 3= Minus (1", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[2].Text.Equals("-3 + -2.6= Minus (5.6", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void SmokeTest_Memory()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(0);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
|
||||
page.StandardOperators.NumberPad.Input(2);
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
|
||||
page.StandardOperators.NumberPad.Input(7);
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(9);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("63", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(memoryItems[1].Text.Equals("0.6666666666666667", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(memoryItems[2].Text.Equals("3", StringComparison.InvariantCultureIgnoreCase));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Basic Arthimetic Tests
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Operator_Reciprocal()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(4);
|
||||
page.StandardOperators.InvertButton.Click();
|
||||
Assert.AreEqual("0.25", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Operator_Squared()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(-15.5);
|
||||
page.StandardOperators.XPower2Button.Click();
|
||||
Assert.AreEqual("240.25", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Operator_SquareRoot()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(144);
|
||||
page.StandardOperators.SquareRootButton.Click();
|
||||
Assert.AreEqual("12", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Operator_Percent()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(600);
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(15);
|
||||
page.StandardOperators.PercentButton.Click();
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("90", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void Operator_Delete()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(-12345);
|
||||
page.StandardOperators.BackSpaceButton.Click();
|
||||
Assert.AreEqual("-1,234", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void Operator_ClearAll()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(12345);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(6789);
|
||||
page.StandardOperators.ClearButton.Click();
|
||||
Assert.AreEqual("0", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void Operator_ClearEntry()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(-12345);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(5678);
|
||||
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText()); //verifies subtraction
|
||||
page.StandardOperators.ClearEntryButton.Click();
|
||||
Assert.AreEqual("0", page.GetCalculatorResultText());
|
||||
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText()); //verifies the CE button
|
||||
page.StandardOperators.ClearButton.Click();
|
||||
page.CalculatorResults.IsResultsExpressionClear(); //verifies the C button
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Keyboard Input Tests
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void KeyboardInput_Subtract()
|
||||
public void MouseInput_MultiplyDivideEqualFourFiveSix()
|
||||
{
|
||||
page.Header.SendKeys("70090-890987=");
|
||||
Assert.AreEqual("-820,897", page.GetCalculatorResultText());
|
||||
//Verifies the multiplication, and division, and the x, ÷, equal, 4, 5, and 6 button
|
||||
page.StandardOperators.NumberPad.Num4Button.Click();
|
||||
Assert.AreEqual("4", page.CalculatorResults.GetCalculatorResultText()); //verifies 4 button
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
Assert.AreEqual("4 ×", page.CalculatorResults.GetCalculatorExpressionText()); //verifies x button
|
||||
page.StandardOperators.NumberPad.Num5Button.Click();
|
||||
Assert.AreEqual("5", page.CalculatorResults.GetCalculatorResultText()); //verifies 5 button
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
Assert.AreEqual("20", page.CalculatorResults.GetCalculatorResultText()); //verifies multiplication
|
||||
Assert.AreEqual("4 × 5 ÷", page.CalculatorResults.GetCalculatorExpressionText()); //verifies ÷ button
|
||||
page.StandardOperators.NumberPad.Num6Button.Click();
|
||||
Assert.AreEqual("6", page.CalculatorResults.GetCalculatorResultText()); //verifies 6 button
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("3.333333333333333", page.CalculatorResults.GetCalculatorResultText()); //verifies division
|
||||
Assert.AreEqual("4 × 5 ÷ 6=", page.CalculatorResults.GetCalculatorExpressionText()); //verifies = button
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void MouseInput_InvertSquaredSevenEightNine()
|
||||
{
|
||||
//Verifies the invert, squared, 7, 8, and 9 button
|
||||
page.StandardOperators.NumberPad.Num7Button.Click();
|
||||
Assert.AreEqual("7", page.CalculatorResults.GetCalculatorResultText()); //verifies 7 button
|
||||
page.StandardOperators.InvertButton.Click();
|
||||
Assert.AreEqual("0.1428571428571429", page.CalculatorResults.GetCalculatorResultText()); //verifies inversion
|
||||
Assert.AreEqual("1/(7)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies the invert button
|
||||
page.StandardOperators.ClearButton.Click();
|
||||
page.StandardOperators.NumberPad.Num8Button.Click();
|
||||
Assert.AreEqual("8", page.CalculatorResults.GetCalculatorResultText()); //verifies 8 button
|
||||
page.StandardOperators.ClearButton.Click();
|
||||
page.StandardOperators.NumberPad.Num9Button.Click();
|
||||
Assert.AreEqual("9", page.CalculatorResults.GetCalculatorResultText()); //verifies 9 button
|
||||
page.StandardOperators.XPower2Button.Click();
|
||||
Assert.AreEqual("81", page.CalculatorResults.GetCalculatorResultText()); //verifies squaring
|
||||
Assert.AreEqual("square (9)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies squared button
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void MouseInput_PercentSquareRootBackspaceDecimalNegateOneZero()
|
||||
{
|
||||
//Verifies the %, square root, backspace, decimal, negate, 1, and 0 button
|
||||
page.StandardOperators.NumberPad.Num1Button.Click();
|
||||
page.StandardOperators.NumberPad.Num0Button.Click();
|
||||
page.StandardOperators.NumberPad.Num0Button.Click();
|
||||
page.StandardOperators.BackSpaceButton.Click();
|
||||
Assert.AreEqual("10", page.CalculatorResults.GetCalculatorResultText()); // verifies the 1 button, the 0 button, and the backspace button
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.PercentButton.Click();
|
||||
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText()); //verifies percent calculation
|
||||
Assert.AreEqual("10 + 1", page.CalculatorResults.GetCalculatorExpressionText()); //verifies percent button
|
||||
page.StandardOperators.PercentButton.Click();
|
||||
page.StandardOperators.SquareRootButton.Click();
|
||||
Assert.AreEqual("0.3162277660168379", page.CalculatorResults.GetCalculatorResultText()); //verifies square root calculation
|
||||
Assert.AreEqual("10 + √(0.1)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies 2√x button
|
||||
page.StandardOperators.NumberPad.DecimalButton.Click();
|
||||
Assert.AreEqual("0 point", page.CalculatorResults.GetCalculatorResultText()); //verifies decimal button
|
||||
page.StandardOperators.NumberPad.NegateButton.Click();
|
||||
page.StandardOperators.NumberPad.Num1Button.Click();
|
||||
Assert.AreEqual("-0.1", page.CalculatorResults.GetCalculatorResultText()); //verifies negate button
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("9.9", page.CalculatorResults.GetCalculatorResultText()); //verifies calculation with decimal point and negative number
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void MouseInput_HistoryButtons()
|
||||
{
|
||||
//Verifies history buttons
|
||||
page.StandardOperators.NumberPad.Num4Button.Click();
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
page.StandardOperators.NumberPad.Num5Button.Click();
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
page.StandardOperators.NumberPad.Num6Button.Click();
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
page.HistoryPanel.ResizeWindowToDisplayHistoryButton();
|
||||
page.HistoryPanel.HistoryButton.Click();
|
||||
var historyFlyoutItems = page.HistoryPanel.GetAllHistoryFlyoutListViewItems();
|
||||
Assert.IsTrue(historyFlyoutItems[0].Text.Equals("4 × 5 ÷ 6= 3.333333333333333", StringComparison.InvariantCultureIgnoreCase)); //verifies History button
|
||||
page.HistoryPanel.ResizeWindowToDisplayHistoryLabel();
|
||||
var historyItems = page.HistoryPanel.GetAllHistoryListViewItems();
|
||||
Assert.IsTrue(historyItems[0].Text.Equals("4 × 5 ÷ 6= 3.333333333333333", StringComparison.InvariantCultureIgnoreCase));
|
||||
page.HistoryPanel.ClearHistoryButton.Click();
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("HistoryEmpty")); //verifies the History panel's clear history button
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void MouseInput_MemoryButtons()
|
||||
{
|
||||
//Verifies memory buttons
|
||||
page.StandardOperators.NumberPad.Num1Button.Click();
|
||||
page.MemoryPanel.NumberpadMSButton.Click();
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("1", StringComparison.InvariantCultureIgnoreCase)); //verifies memory button
|
||||
page.MemoryPanel.NumberpadMPlusButton.Click();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("2", StringComparison.InvariantCultureIgnoreCase)); //verifies memory plus button
|
||||
page.MemoryPanel.NumberpadMRButton.Click();
|
||||
Assert.AreEqual("2", page.CalculatorResults.GetCalculatorResultText()); //verifies memory recall button
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.Num1Button.Click();
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
page.MemoryPanel.NumberpadMMinusButton.Click();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("1", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText()); //verifies MemMinus button
|
||||
page.MemoryPanel.NumberpadMCButton.Click();
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("MemoryPaneEmpty")); //verifies the Memory panel's memory clear button
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Basic Calculator Functionality via Keyboard Input Tests
|
||||
|
||||
/// <summary>
|
||||
/// These automated tests verify the functionality of all hotkeys, that are common for all calculator modes, as well as the all keyboard input used in standard mode on the Standard Calculator.
|
||||
/// Via keyboard input, all basic UI functionality is checked.
|
||||
/// To-do:
|
||||
/// - Active issue "Bug 23811901: Clicking on the History Label causes the [Shift] + [Ctrl] + [D] hotkeys to break" causes KeyboardInput_HistoryHotkeys() to fail.
|
||||
/// It is currently commented out until the active bug is fixed.
|
||||
/// </summary>
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void KeyboardInput_HotkeysToChangeToBasicModes()
|
||||
{
|
||||
// Verify Hotkeys for changing modes
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Alt + "2" + Keys.Alt);
|
||||
Assert.AreEqual("Scientific", CalculatorApp.GetCalculatorHeaderText()); //verifies Scientific navigation hotkey
|
||||
|
||||
//To-do: Waiting for hotkey difinitions to become settled once graphing calculator is full add into the build process
|
||||
//CalculatorApp.EnsureCalculatorHasFocus();
|
||||
//CalculatorApp.Window.SendKeys(Keys.Alt + "4" + Keys.Alt);
|
||||
//Assert.AreEqual("Programmer", CalculatorApp.GetCalculatorHeaderText()); //verifies Programmer navigation hotkey
|
||||
//CalculatorApp.EnsureCalculatorHasFocus();
|
||||
//CalculatorApp.Window.SendKeys(Keys.Alt + "5" + Keys.Alt);
|
||||
//Assert.AreEqual("Date Calculation", CalculatorApp.GetCalculatorHeaderText()); //verifies Date Calculation navigation hotkey
|
||||
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Alt + "1" + Keys.Alt);
|
||||
Assert.AreEqual("Standard", CalculatorApp.GetCalculatorHeaderText()); //verifies Standard navigation hotkey
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void KeyboardInput_Multiply()
|
||||
public void KeyboardInput_AddSubtractClearClearEntryTwoThree()
|
||||
{
|
||||
page.Header.SendKeys("-15*3=");
|
||||
Assert.AreEqual("-45", page.GetCalculatorResultText());
|
||||
//Verifies the +, -, CE, C, 2, and 3 button
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("2");
|
||||
Assert.AreEqual("2", page.CalculatorResults.GetCalculatorResultText()); //verifies using 2 key
|
||||
CalculatorApp.Window.SendKeys(Keys.Add);
|
||||
Assert.AreEqual("2 +", page.CalculatorResults.GetCalculatorExpressionText()); //verifies using add key
|
||||
CalculatorApp.Window.SendKeys("2");
|
||||
CalculatorApp.Window.SendKeys(Keys.Subtract);
|
||||
Assert.AreEqual("4", page.CalculatorResults.GetCalculatorResultText()); //verifies addition
|
||||
Assert.AreEqual("2 + 2 Minus (", page.CalculatorResults.GetCalculatorExpressionText()); //verifies using subtraction key
|
||||
CalculatorApp.Window.SendKeys("3");
|
||||
Assert.AreEqual("3", page.CalculatorResults.GetCalculatorResultText()); //verifies using 3 key
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText()); //verifies subtraction
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Delete);
|
||||
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText()); //verifies the CE hotkey
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
page.CalculatorResults.IsResultsExpressionClear(); //verifies the C hotkey
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void KeyboardInput_Divide()
|
||||
public void KeyboardInput_MultiplyDivideEqualFourFiveSix()
|
||||
{
|
||||
page.Header.SendKeys("26/13=");
|
||||
Assert.AreEqual("2", page.GetCalculatorResultText());
|
||||
//Verifies the multiplication, division, and equal, 4, 5, and 6 key input
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("4");
|
||||
Assert.AreEqual("4", page.CalculatorResults.GetCalculatorResultText()); //verifies using 4 key
|
||||
CalculatorApp.Window.SendKeys(Keys.Multiply);
|
||||
Assert.AreEqual("4 ×", page.CalculatorResults.GetCalculatorExpressionText()); //verifies using multiplication key
|
||||
CalculatorApp.Window.SendKeys("5");
|
||||
Assert.AreEqual("5", page.CalculatorResults.GetCalculatorResultText()); //verifies using 5 key
|
||||
CalculatorApp.Window.SendKeys(Keys.Divide);
|
||||
Assert.AreEqual("20", page.CalculatorResults.GetCalculatorResultText()); //verifies multiplication
|
||||
Assert.AreEqual("4 × 5 ÷", page.CalculatorResults.GetCalculatorExpressionText()); //verifies using divide key
|
||||
CalculatorApp.Window.SendKeys("6");
|
||||
Assert.AreEqual("6", page.CalculatorResults.GetCalculatorResultText()); //verifies using 6 key
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("3.333333333333333", page.CalculatorResults.GetCalculatorResultText()); //verifies division
|
||||
Assert.AreEqual("4 × 5 ÷ 6=", page.CalculatorResults.GetCalculatorExpressionText()); //verifies equal key
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void KeyboardInput_SquareRoot()
|
||||
public void KeyboardInput_InvertSquaredSevenEightNine()
|
||||
{
|
||||
page.Header.SendKeys("100@");
|
||||
Assert.AreEqual("10", page.GetCalculatorResultText());
|
||||
//Verifies the invert, squared, 7, 8, and 9 key input
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("7");
|
||||
Assert.AreEqual("7", page.CalculatorResults.GetCalculatorResultText()); //verifies using 7 key
|
||||
CalculatorApp.Window.SendKeys("r");
|
||||
Assert.AreEqual("0.1428571428571429", page.CalculatorResults.GetCalculatorResultText()); //verifies inversion
|
||||
Assert.AreEqual("1/(7)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies the invert hotkey
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
CalculatorApp.Window.SendKeys("8");
|
||||
Assert.AreEqual("8", page.CalculatorResults.GetCalculatorResultText()); //verifies using 8 key
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
CalculatorApp.Window.SendKeys("9");
|
||||
Assert.AreEqual("9", page.CalculatorResults.GetCalculatorResultText()); //verifies using 9 key
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("q");
|
||||
Assert.AreEqual("81", page.CalculatorResults.GetCalculatorResultText()); //verifies squaring
|
||||
Assert.AreEqual("square (9)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies squared hotkey
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void KeyboardInput_Percent()
|
||||
public void KeyboardInput_PercentSquareRootBackspaceDecimalNegateOneZero()
|
||||
{
|
||||
page.Header.SendKeys("34+7%=");
|
||||
Assert.AreEqual("36.38", page.GetCalculatorResultText());
|
||||
//Verifies the %, square root, backspace, decimal, negate, 1, and 0 button
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("100");
|
||||
CalculatorApp.Window.SendKeys(Keys.Backspace);
|
||||
Assert.AreEqual("10", page.CalculatorResults.GetCalculatorResultText()); // verifies using the 1 key, the 0 key, and the backspace key
|
||||
CalculatorApp.Window.SendKeys(Keys.Add);
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Shift + "5" + Keys.Shift);
|
||||
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText()); //verifies percent calculation
|
||||
Assert.AreEqual("10 + 1", page.CalculatorResults.GetCalculatorExpressionText()); //verifies percent hotkey
|
||||
CalculatorApp.Window.SendKeys(Keys.Shift);
|
||||
CalculatorApp.Window.SendKeys(Keys.Shift + "5" + Keys.Shift);
|
||||
CalculatorApp.Window.SendKeys(Keys.Shift);
|
||||
CalculatorApp.Window.SendKeys(Keys.Shift + "2" + Keys.Shift);
|
||||
Assert.AreEqual("0.3162277660168379", page.CalculatorResults.GetCalculatorResultText()); //verifies square root calculation
|
||||
Assert.AreEqual("10 + √(0.1)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies 2√x hotkey
|
||||
CalculatorApp.Window.SendKeys(".");
|
||||
Assert.AreEqual("0 point", page.CalculatorResults.GetCalculatorResultText()); //verifies using decimal key
|
||||
CalculatorApp.Window.SendKeys(Keys.F9);
|
||||
CalculatorApp.Window.SendKeys("1");
|
||||
Assert.AreEqual("-0.1", page.CalculatorResults.GetCalculatorResultText()); //verifies negate hotkey
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("9.9", page.CalculatorResults.GetCalculatorResultText()); //verifies calculation with decimal point and negative number
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void KeyboardInput_MemoryHotkeys()
|
||||
{
|
||||
//Verifies memory buttons
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("1");
|
||||
CalculatorApp.Window.SendKeys(Keys.Control + "m" + Keys.Control);
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("1", StringComparison.InvariantCultureIgnoreCase)); //verifies memory hotkey
|
||||
CalculatorApp.Window.SendKeys(Keys.Control + "p" + Keys.Control);
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("2", StringComparison.InvariantCultureIgnoreCase)); //verifies memory plus hotkey
|
||||
CalculatorApp.Window.SendKeys(Keys.Control + "r" + Keys.Control);
|
||||
Assert.AreEqual("2", page.CalculatorResults.GetCalculatorResultText()); //verifies memory recall hotkey
|
||||
CalculatorApp.Window.SendKeys(Keys.Subtract);
|
||||
CalculatorApp.Window.SendKeys("1");
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
CalculatorApp.Window.SendKeys(Keys.Subtract);
|
||||
CalculatorApp.Window.SendKeys(Keys.Control + "q" + Keys.Control);
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("1", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText()); //verifies MemMinus hotkey
|
||||
CalculatorApp.Window.SendKeys(Keys.Control + "l" + Keys.Control);
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("MemoryPaneEmpty")); //verifies the Memory panel's memory clear button hotkey
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Memory Tests
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Memory_AddTest()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(12);
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
#region Arithmetic Operators Functionality via Mixed Input
|
||||
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(15);
|
||||
page.MemoryPanel.MemPlus.Click();
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("19", StringComparison.InvariantCultureIgnoreCase));
|
||||
/// <summary>
|
||||
/// These automated test not only verify each opperator individually, but they also simultaneously verify mixed user input.
|
||||
/// Arithmetic Operators for standard calculator are also automated in:
|
||||
/// - Region: Basic UI Functionality via Mouse input
|
||||
/// - Region: Basic Calculator Functionality via Keyboard input
|
||||
/// </summary>
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Addition()
|
||||
{
|
||||
|
||||
//Verify Addition
|
||||
page.StandardOperators.NumberPad.Input(2);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("2");
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("4", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Subtraction()
|
||||
{
|
||||
//Verify Subtraction
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("2");
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Multiplication()
|
||||
{
|
||||
//Verify Multiplication
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("2");
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("6", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Division()
|
||||
{
|
||||
//Verify Division
|
||||
page.StandardOperators.NumberPad.Input(6);
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("2");
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("12", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Reciprocal()
|
||||
{
|
||||
//Verify Reciprocal
|
||||
page.StandardOperators.NumberPad.Input(2);
|
||||
page.StandardOperators.InvertButton.Click();
|
||||
Assert.AreEqual("0.5", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Square()
|
||||
{
|
||||
//Verify Square
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.XPower2Button.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("9", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_SquareRoot()
|
||||
{
|
||||
//Verify Square root
|
||||
page.StandardOperators.NumberPad.Input(9);
|
||||
page.StandardOperators.XPower2Button.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("81", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_PercentAdditionSubtraction()
|
||||
{
|
||||
//Verify Percent addition/subtraction
|
||||
page.StandardOperators.NumberPad.Input(10);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("10");
|
||||
page.StandardOperators.PercentButton.Click();
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("9", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_PercentMultiplicationDivision()
|
||||
{
|
||||
//Verify Percent multiplication/division
|
||||
page.StandardOperators.NumberPad.Input(10);
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("10");
|
||||
page.StandardOperators.PercentButton.Click();
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_PositiveNegative()
|
||||
{
|
||||
//Verify Positive/Negative (plus/minus)
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("2");
|
||||
page.StandardOperators.NegateButton.Click();
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("5", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Decimal()
|
||||
{
|
||||
//Verify Decimal
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.NumberPad.DecimalButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys("2");
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("3.2", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Equal()
|
||||
{
|
||||
//Verify Equal
|
||||
page.HistoryPanel.ClearHistory();
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Equal);
|
||||
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
|
||||
var historyItems = page.HistoryPanel.GetAllHistoryListViewItems();
|
||||
Assert.IsTrue(historyItems[0].Text.Equals("0= 0", StringComparison.InvariantCultureIgnoreCase));
|
||||
Assert.IsTrue(historyItems[1].Text.Equals("0= 0", StringComparison.InvariantCultureIgnoreCase));
|
||||
CalculatorApp.Window.SendKeys(Keys.Escape);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_Delete()
|
||||
{
|
||||
//Verify Delete
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
CalculatorApp.Window.SendKeys("3");
|
||||
Assert.AreEqual("33", page.CalculatorResults.GetCalculatorResultText());
|
||||
page.StandardOperators.BackSpaceButton.Click();
|
||||
Assert.AreEqual("3", page.CalculatorResults.GetCalculatorResultText());
|
||||
CalculatorApp.Window.SendKeys(Keys.Backspace);
|
||||
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void MixedInput_Operators_ClearEntryClear()
|
||||
{
|
||||
//Verify Clear Entery
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
CalculatorApp.Window.SendKeys(Keys.Add);
|
||||
CalculatorApp.Window.SendKeys("3");
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
CalculatorApp.Window.SendKeys(Keys.Delete);
|
||||
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
|
||||
Assert.AreEqual("3 +", page.CalculatorResults.GetCalculatorExpressionText());
|
||||
|
||||
page.StandardOperators.NumberPad.Input(9);
|
||||
CalculatorApp.Window.SendKeys(Keys.Subtract);
|
||||
CalculatorApp.Window.SendKeys("6");
|
||||
page.StandardOperators.ClearEntryButton.Click();
|
||||
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
|
||||
Assert.AreEqual("3 + 9 Minus (", page.CalculatorResults.GetCalculatorExpressionText());
|
||||
|
||||
//Verify Clear
|
||||
page.StandardOperators.NumberPad.Input(6);
|
||||
CalculatorApp.Window.SendKeys(Keys.Subtract);
|
||||
CalculatorApp.Window.SendKeys("9");
|
||||
page.StandardOperators.ClearButton.Click();
|
||||
page.CalculatorResults.IsResultsExpressionClear();
|
||||
}
|
||||
|
||||
// Issue #817: Prefixed multiple zeros
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void MixedInput_Operators_DeletingDecimalDoesNotPrefixZeros()
|
||||
{
|
||||
page.StandardOperators.NumberPad.DecimalButton.Click(); // To enter decimal point
|
||||
CalculatorApp.Window.SendKeys("1");
|
||||
page.StandardOperators.BackSpaceButton.Click();
|
||||
page.StandardOperators.BackSpaceButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(0);
|
||||
page.StandardOperators.NumberPad.Num0Button.Click();
|
||||
page.StandardOperators.NumberPad.Input(0);
|
||||
Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AoT (Always on top) Tests
|
||||
/// <summary>
|
||||
/// These automated tests verify:
|
||||
/// - Calculator can enter AoT mode, the AoT window is within a range of size, and it verifies exiting AoT mode
|
||||
/// - AoT button tooltips (in English)
|
||||
/// - Memory function cannot be triggered in AoT calculator
|
||||
/// - The history flyout cannot be opened in AoT mode and that history is tracked while in AoT mode and available upon exit of AoT mode
|
||||
/// - That Standard calculator has AoT button, but other major calculator modes do not
|
||||
/// - That the app can scale to smallest size, largest size, and to a medium size without crashing. It does not test the visual appears of the UI while scaling.
|
||||
/// - The window scale retention is maintained when switching between AoT and Non-AoT
|
||||
/// - To-do: Verify scale retention across calculator session
|
||||
/// - Error messaging while AoT mode
|
||||
/// - To-do: Need to verify "All operator buttons (except for "CE", "C", "Delete" and "="), and memory buttons are disabled" when in AoT mode
|
||||
/// - Verify app positioning after entering and exiting KOT mode
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void AoT_EnterExitKeepOnTop()
|
||||
{
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardAoTMode();
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardMode();
|
||||
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(0)]
|
||||
public void AoT_Tootip()
|
||||
{
|
||||
Assert.AreEqual("Keep on top (Alt+Up)", page.StandardAoTCalculatorPage.GetAoTToolTipText());
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardAoTMode();
|
||||
Assert.AreEqual("Back to full view (Alt+Down)", page.StandardAoTCalculatorPage.GetAoTToolTipText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Memory_SubtractTest()
|
||||
public void AoT_NoMemoryFunction()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(12);
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3.3);
|
||||
page.MemoryPanel.MemMinus.Click();
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("0.7", StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Memory_RecallTest()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(12);
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3.3);
|
||||
page.MemoryPanel.MemRecall.Click();
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("4", StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Memory_ClearTest()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(12);
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3.3);
|
||||
page.MemoryPanel.MemoryClear.Click();
|
||||
page.StandardOperators.NumberPad.Num9Button.Click();
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.Num3Button.Click();
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardAoTMode();
|
||||
CalculatorApp.Window.SendKeys(Keys.Enter);
|
||||
CalculatorApp.Window.SendKeys(Keys.Control + "P" + Keys.Control);
|
||||
CalculatorApp.Window.SendKeys(Keys.Shift); //Hotkeys such as "Delete" will break without this line
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardMode();
|
||||
page.MemoryPanel.OpenMemoryPanel();
|
||||
Assert.IsNotNull(page.MemoryPanel.MemoryPaneEmptyLabel);
|
||||
Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("MemoryPaneEmpty"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void AoT_HistoryFunction()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Num3Button.Click();
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Num3Button.Click();
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardAoTMode();
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
CalculatorApp.Window.SendKeys(Keys.Control + "H" + Keys.Control);
|
||||
string source = WinAppDriver.Instance.CalculatorSession.PageSource;
|
||||
if (source.Contains("HistoryFlyout"))
|
||||
{
|
||||
throw new NotFoundException("This test fails; history flyout is present");
|
||||
}
|
||||
else
|
||||
{
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardMode();
|
||||
var historyItems = page.HistoryPanel.GetAllHistoryListViewItems();
|
||||
Assert.IsTrue(historyItems[0].Text.Equals("3 + 3= 6", StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void AoT_ButtonOnlyInStandard()
|
||||
{
|
||||
page.NavigationMenu.ChangeCalculatorMode(CalculatorMode.ScientificCalculator);
|
||||
Assert.AreEqual("Scientific", CalculatorApp.GetCalculatorHeaderText());
|
||||
page.StandardAoTCalculatorPage.GetAoTPresence();
|
||||
Assert.AreEqual("False", page.StandardAoTCalculatorPage.GetAoTPresence());
|
||||
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
page.NavigationMenu.ChangeCalculatorMode(CalculatorMode.ProgrammerCalculator);
|
||||
Assert.AreEqual("Programmer", CalculatorApp.GetCalculatorHeaderText());
|
||||
page.StandardAoTCalculatorPage.GetAoTPresence();
|
||||
Assert.AreEqual("False", page.StandardAoTCalculatorPage.GetAoTPresence());
|
||||
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
page.NavigationMenu.ChangeCalculatorMode(CalculatorMode.DateCalculator);
|
||||
Assert.AreEqual("Date Calculation", CalculatorApp.GetCalculatorHeaderText());
|
||||
page.StandardAoTCalculatorPage.GetAoTPresence();
|
||||
Assert.AreEqual("False", page.StandardAoTCalculatorPage.GetAoTPresence());
|
||||
|
||||
CalculatorApp.EnsureCalculatorHasFocus();
|
||||
page.NavigationMenu.ChangeCalculatorMode(CalculatorMode.StandardCalculator);
|
||||
Assert.AreEqual("Standard", CalculatorApp.GetCalculatorHeaderText());
|
||||
page.StandardAoTCalculatorPage.GetAoTPresence();
|
||||
Assert.AreEqual("True", page.StandardAoTCalculatorPage.GetAoTPresence());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void AoT_ErrorMessage_ResultUndefined()
|
||||
{
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardAoTMode();
|
||||
page.StandardAoTCalculatorPage.ResizeAoTWindowToDisplayInvertButton();
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
page.StandardOperators.NumberPad.Num0Button.Click();
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
page.StandardAoTCalculatorPage.AoTModeCheck();
|
||||
Assert.AreEqual("True", page.StandardAoTCalculatorPage.AoTModeCheck());
|
||||
Assert.AreEqual("Result is undefined", page.CalculatorResults.GetAoTCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void AoT_ErrorMessage_CannotDivideByZero()
|
||||
{
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardAoTMode();
|
||||
page.StandardAoTCalculatorPage.ResizeAoTWindowToDisplayInvertButton();
|
||||
page.StandardOperators.ClearButton.Click();
|
||||
page.StandardOperators.InvertButton.Click();
|
||||
page.StandardAoTCalculatorPage.AoTModeCheck();
|
||||
Assert.AreEqual("True", page.StandardAoTCalculatorPage.AoTModeCheck());
|
||||
Assert.AreEqual("Cannot divide by zero", page.CalculatorResults.GetAoTCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(2)]
|
||||
public void AoT_ErrorMessage_MessageRetentionUponExitingAoT()
|
||||
{
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardAoTMode();
|
||||
page.StandardAoTCalculatorPage.ResizeAoTWindowToDisplayInvertButton();
|
||||
page.StandardOperators.ClearButton.Click();
|
||||
page.StandardOperators.InvertButton.Click();
|
||||
page.StandardAoTCalculatorPage.AoTModeCheck();
|
||||
Assert.AreEqual("True", page.StandardAoTCalculatorPage.AoTModeCheck());
|
||||
Assert.AreEqual("Cannot divide by zero", page.CalculatorResults.GetAoTCalculatorResultText());
|
||||
page.StandardAoTCalculatorPage.NavigateToStandardMode();
|
||||
page.StandardAoTCalculatorPage.AoTModeCheck();
|
||||
Assert.AreEqual("False", page.StandardAoTCalculatorPage.AoTModeCheck());
|
||||
Assert.AreEqual("Cannot divide by zero", page.CalculatorResults.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Error Tests
|
||||
/// <summary>
|
||||
/// These automated tests verify errors display gracefully
|
||||
/// Via mouse input, all basic UI functionality is checked
|
||||
/// </summary>
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Error_DivideByZero()
|
||||
{
|
||||
page.StandardOperators.InvertButton.Click();
|
||||
Assert.IsTrue(page.CalculatorResults.GetCalculatorResultText() == "Cannot divide by zero");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[Priority(1)]
|
||||
public void Error_ErrorSquareRootNegativeNumber()
|
||||
{
|
||||
page.StandardOperators.NumberPad.Input(9);
|
||||
page.StandardOperators.NegateButton.Click();
|
||||
page.StandardOperators.SquareRootButton.Click();
|
||||
Assert.AreEqual("Invalid input", page.CalculatorResults.GetCalculatorResultText());
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user