mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
Resolved code review feedback and added copyright headers
This commit is contained in:
parent
45db18242f
commit
7117b6ba79
13 changed files with 292 additions and 329 deletions
|
@ -105,6 +105,38 @@ Global
|
|||
{D3BAED2C-4B07-4E1D-8807-9D6499450349}.Release|x86.ActiveCfg = Release|Win32
|
||||
{D3BAED2C-4B07-4E1D-8807-9D6499450349}.Release|x86.Build.0 = Release|Win32
|
||||
{D3BAED2C-4B07-4E1D-8807-9D6499450349}.Release|x86.Deploy.0 = Release|Win32
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B2C5ADFF-D6B5-48C1-BB8C-571BFD583D7F}.Release|x86.Build.0 = Release|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{96454213-94AF-457D-9DF9-B14F80E7770F}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -1,32 +1,21 @@
|
|||
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
public class HistoryPanel
|
||||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
public WindowsElement HistoryLabel => session.TryFindElementByAccessibilityId("HistoryLabel");
|
||||
public WindowsElement HistoryListView => session.TryFindElementByAccessibilityId("HistoryListView");
|
||||
public WindowsElement ClearHistoryButton => session.TryFindElementByAccessibilityId("ClearHistory");
|
||||
public WindowsElement HistoryEmptyLabel => session.TryFindElementByAccessibilityId("HistoryEmpty");
|
||||
public WindowsElement HistoryLabel => this.session.TryFindElementByAccessibilityId("HistoryLabel");
|
||||
public WindowsElement HistoryListView => this.session.TryFindElementByAccessibilityId("HistoryListView");
|
||||
public WindowsElement ClearHistoryButton => this.session.TryFindElementByAccessibilityId("ClearHistory");
|
||||
public WindowsElement HistoryEmptyLabel => this.session.TryFindElementByAccessibilityId("HistoryEmpty");
|
||||
|
||||
/// <summary>
|
||||
/// Opens the History Pane by clicking the History pivot label.
|
||||
/// </summary>
|
||||
public void OpenHistoryPanel()
|
||||
{
|
||||
HistoryLabel.Click();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all of the history items listed in the History Pane.
|
||||
|
@ -34,9 +23,9 @@ namespace CalculatorUITestFramework
|
|||
/// <returns>A readonly collection of history items.</returns>
|
||||
public ReadOnlyCollection<AppiumWebElement> GetAllHistoryListViewItems()
|
||||
{
|
||||
OpenHistoryPanel();
|
||||
HistoryListView.WaitForDisplayed();
|
||||
return HistoryListView.FindElementsByClassName("ListViewItem");
|
||||
this.HistoryLabel.Click();
|
||||
this.HistoryListView.WaitForDisplayed();
|
||||
return this.HistoryListView.FindElementsByClassName("ListViewItem");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -44,17 +33,17 @@ namespace CalculatorUITestFramework
|
|||
/// </summary>
|
||||
public void ClearHistory()
|
||||
{
|
||||
OpenHistoryPanel();
|
||||
this.HistoryLabel.Click();
|
||||
|
||||
try
|
||||
{
|
||||
ClearHistoryButton.Click();
|
||||
this.ClearHistoryButton.Click();
|
||||
}
|
||||
catch(WebDriverException ex)
|
||||
{
|
||||
if (ex.Message.Contains("element could not be located"))
|
||||
{
|
||||
Assert.IsNotNull(HistoryEmptyLabel);
|
||||
Assert.IsNotNull(this.HistoryEmptyLabel);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +1,32 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using OpenQA.Selenium.Appium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
public class MemoryPanel
|
||||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
public WindowsElement MemoryClear => session.TryFindElementByAccessibilityId("ClearMemoryButton");
|
||||
public WindowsElement MemRecall => session.TryFindElementByAccessibilityId("MemRecall");
|
||||
public WindowsElement MemPlus => session.TryFindElementByAccessibilityId("MemPlus");
|
||||
public WindowsElement MemMinus => session.TryFindElementByAccessibilityId("MemMinus");
|
||||
public WindowsElement MemButton => session.TryFindElementByAccessibilityId("memButton");
|
||||
public WindowsElement MemoryPane => session.TryFindElementByAccessibilityId("MemoryPanel");
|
||||
public WindowsElement MemoryLabel => session.TryFindElementByAccessibilityId("MemoryLabel");
|
||||
public WindowsElement MemoryListView => session.TryFindElementByAccessibilityId("MemoryListView");
|
||||
public WindowsElement MemoryPaneEmptyLabel => session.TryFindElementByAccessibilityId("MemoryPaneEmpty");
|
||||
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");
|
||||
|
||||
/// <summary>
|
||||
/// Opens the Memory Pane by clicking the Memory pivot label.
|
||||
/// </summary>
|
||||
public void OpenMemoryPanel()
|
||||
{
|
||||
MemoryLabel.Click();
|
||||
MemoryPane.WaitForDisplayed();
|
||||
this.MemoryLabel.Click();
|
||||
this.MemoryPane.WaitForDisplayed();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -39,7 +36,7 @@ namespace CalculatorUITestFramework
|
|||
public ReadOnlyCollection<AppiumWebElement> GetAllMemoryListViewItems()
|
||||
{
|
||||
OpenMemoryPanel();
|
||||
return MemoryListView.FindElementsByClassName("ListViewItem");
|
||||
return this.MemoryListView.FindElementsByClassName("ListViewItem");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
|
@ -30,8 +30,8 @@ namespace CalculatorUITestFramework
|
|||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
|
||||
public WindowsElement NavigationMenuButton => session.TryFindElementByAccessibilityId("TogglePaneButton");
|
||||
public WindowsElement NavigationMenuPane => session.TryFindElementByClassName("SplitViewPane");
|
||||
public WindowsElement NavigationMenuButton => this.session.TryFindElementByAccessibilityId("TogglePaneButton");
|
||||
public WindowsElement NavigationMenuPane => this.session.TryFindElementByClassName("SplitViewPane");
|
||||
|
||||
/// <summary>
|
||||
/// Changes the mode using the navigation menu in the UI
|
||||
|
@ -94,14 +94,12 @@ namespace CalculatorUITestFramework
|
|||
modeAccessibilityId = "Angle";
|
||||
break;
|
||||
default:
|
||||
modeAccessibilityId = string.Empty;
|
||||
break;
|
||||
throw (new ArgumentException("The mode is not valid"));
|
||||
}
|
||||
|
||||
var source = session.PageSource;
|
||||
NavigationMenuButton.Click();
|
||||
NavigationMenuPane.WaitForDisplayed();
|
||||
session.TryFindElementByAccessibilityId(modeAccessibilityId).Click();
|
||||
this.NavigationMenuButton.Click();
|
||||
this.NavigationMenuPane.WaitForDisplayed();
|
||||
this.session.TryFindElementByAccessibilityId(modeAccessibilityId).Click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,76 +1,80 @@
|
|||
using System;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
public class NumerPad
|
||||
{
|
||||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
public WindowsElement Num0Button => session.TryFindElementByAccessibilityId("num0Button");
|
||||
public WindowsElement Num1Button => session.TryFindElementByAccessibilityId("num1Button");
|
||||
public WindowsElement Num2Button => session.TryFindElementByAccessibilityId("num2Button");
|
||||
public WindowsElement Num3Button => session.TryFindElementByAccessibilityId("num3Button");
|
||||
public WindowsElement Num4Button => session.TryFindElementByAccessibilityId("num4Button");
|
||||
public WindowsElement Num5Button => session.TryFindElementByAccessibilityId("num5Button");
|
||||
public WindowsElement Num6Button => session.TryFindElementByAccessibilityId("num6Button");
|
||||
public WindowsElement Num7Button => session.TryFindElementByAccessibilityId("num7Button");
|
||||
public WindowsElement Num8Button => session.TryFindElementByAccessibilityId("num8Button");
|
||||
public WindowsElement Num9Button => session.TryFindElementByAccessibilityId("num9Button");
|
||||
public WindowsElement DecimalButton => session.TryFindElementByAccessibilityId("decimalSeparatorButton");
|
||||
public WindowsElement NegateButton => session.TryFindElementByAccessibilityId("negateButton");
|
||||
public WindowsElement Num0Button => this.session.TryFindElementByAccessibilityId("num0Button");
|
||||
public WindowsElement Num1Button => this.session.TryFindElementByAccessibilityId("num1Button");
|
||||
public WindowsElement Num2Button => this.session.TryFindElementByAccessibilityId("num2Button");
|
||||
public WindowsElement Num3Button => this.session.TryFindElementByAccessibilityId("num3Button");
|
||||
public WindowsElement Num4Button => this.session.TryFindElementByAccessibilityId("num4Button");
|
||||
public WindowsElement Num5Button => this.session.TryFindElementByAccessibilityId("num5Button");
|
||||
public WindowsElement Num6Button => this.session.TryFindElementByAccessibilityId("num6Button");
|
||||
public WindowsElement Num7Button => this.session.TryFindElementByAccessibilityId("num7Button");
|
||||
public WindowsElement Num8Button => this.session.TryFindElementByAccessibilityId("num8Button");
|
||||
public WindowsElement Num9Button => this.session.TryFindElementByAccessibilityId("num9Button");
|
||||
public WindowsElement DecimalButton => this.session.TryFindElementByAccessibilityId("decimalSeparatorButton");
|
||||
public WindowsElement NegateButton => this.session.TryFindElementByAccessibilityId("negateButton");
|
||||
|
||||
/// <summary>
|
||||
/// Translates a number into the Calculator button clicks.
|
||||
/// </summary>
|
||||
/// <param name="number">Number to be entered into the calculator.</param>
|
||||
public void TranslateNumberToButtonClicks(double number)
|
||||
public void Input(double number)
|
||||
{
|
||||
string numberStr = number.ToString();
|
||||
if (numberStr.StartsWith("-"))
|
||||
{
|
||||
numberStr = numberStr.Remove(0, 1);
|
||||
numberStr += '-';
|
||||
numberStr = numberStr.Substring(1) + "-";
|
||||
}
|
||||
foreach (char digit in numberStr)
|
||||
{
|
||||
switch (digit)
|
||||
{
|
||||
case '0':
|
||||
Num0Button.Click();
|
||||
this.Num0Button.Click();
|
||||
break;
|
||||
case '1':
|
||||
Num1Button.Click();
|
||||
this.Num1Button.Click();
|
||||
break;
|
||||
case '2':
|
||||
Num2Button.Click();
|
||||
this.Num2Button.Click();
|
||||
break;
|
||||
case '3':
|
||||
Num3Button.Click();
|
||||
this.Num3Button.Click();
|
||||
break;
|
||||
case '4':
|
||||
Num4Button.Click();
|
||||
this.Num4Button.Click();
|
||||
break;
|
||||
case '5':
|
||||
Num5Button.Click();
|
||||
this.Num5Button.Click();
|
||||
break;
|
||||
case '6':
|
||||
Num6Button.Click();
|
||||
this.Num6Button.Click();
|
||||
break;
|
||||
case '7':
|
||||
Num7Button.Click();
|
||||
this.Num7Button.Click();
|
||||
break;
|
||||
case '8':
|
||||
Num8Button.Click();
|
||||
this.Num8Button.Click();
|
||||
break;
|
||||
case '9':
|
||||
Num9Button.Click();
|
||||
this.Num9Button.Click();
|
||||
break;
|
||||
case '.':
|
||||
DecimalButton.Click();
|
||||
this.DecimalButton.Click();
|
||||
break;
|
||||
case '-':
|
||||
NegateButton.Click();
|
||||
this.NegateButton.Click();
|
||||
break;
|
||||
default:
|
||||
throw (new ArgumentException(String.Format("{0} is not valid", digit)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Remote;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
|
@ -25,15 +22,15 @@ namespace CalculatorUITestFramework
|
|||
{
|
||||
try
|
||||
{
|
||||
return session.TryFindElementByAccessibilityId("Header");
|
||||
return this.session.TryFindElementByAccessibilityId("Header");
|
||||
}
|
||||
catch
|
||||
{
|
||||
return session.TryFindElementByAccessibilityId("ContentPresenter");
|
||||
return this.session.TryFindElementByAccessibilityId("ContentPresenter");
|
||||
}
|
||||
}
|
||||
}
|
||||
public WindowsElement CalculatorResult => session.TryFindElementByAccessibilityId("CalculatorResults");
|
||||
public WindowsElement CalculatorResult => this.session.TryFindElementByAccessibilityId("CalculatorResults");
|
||||
|
||||
public void StandardCalculatorSetup(TestContext context)
|
||||
{
|
||||
|
@ -41,7 +38,7 @@ namespace CalculatorUITestFramework
|
|||
WinAppDriver.Instance.SetupCalculatorSession(context);
|
||||
|
||||
// Ensure that calculator is in standard mode
|
||||
NavigationMenu.ChangeCalculatorMode(CalculatorMode.StandardCalculator);
|
||||
this.NavigationMenu.ChangeCalculatorMode(CalculatorMode.StandardCalculator);
|
||||
Assert.IsNotNull(CalculatorResult);
|
||||
}
|
||||
|
||||
|
@ -57,9 +54,9 @@ namespace CalculatorUITestFramework
|
|||
/// <param name="clearHistory">Bool specifying if the History Panel should be cleared; true by default.</param>
|
||||
public void ClearAll()
|
||||
{
|
||||
StandardOperators.ClearButton.Click();
|
||||
MemoryPanel.MemoryClear.Click();
|
||||
HistoryPanel.ClearHistory();
|
||||
this.StandardOperators.ClearButton.Click();
|
||||
this.MemoryPanel.MemoryClear.Click();
|
||||
this.HistoryPanel.ClearHistory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -68,7 +65,7 @@ namespace CalculatorUITestFramework
|
|||
/// <returns>The string shown in the UI.</returns>
|
||||
public string GetCalculatorResultText()
|
||||
{
|
||||
return CalculatorResult.Text.Replace("Display is", string.Empty).Trim();
|
||||
return this.CalculatorResult.Text.Replace("Display is", string.Empty).Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
|
@ -15,142 +14,18 @@ namespace CalculatorUITestFramework
|
|||
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
|
||||
public NumerPad NumberPad = new NumerPad();
|
||||
|
||||
public WindowsElement PercentButton => session.TryFindElementByAccessibilityId("percentButton");
|
||||
public WindowsElement SquareRootButton => session.TryFindElementByAccessibilityId("squareRootButton");
|
||||
public WindowsElement XPower2Button => session.TryFindElementByAccessibilityId("xpower2Button");
|
||||
public WindowsElement XPower3Button => session.TryFindElementByAccessibilityId("xpower3Button");
|
||||
public WindowsElement InvertButton => session.TryFindElementByAccessibilityId("invertButton");
|
||||
public WindowsElement DivideButton => session.TryFindElementByAccessibilityId("divideButton");
|
||||
public WindowsElement MultiplyButton => session.TryFindElementByAccessibilityId("multiplyButton");
|
||||
public WindowsElement MinusButton => session.TryFindElementByAccessibilityId("minusButton");
|
||||
public WindowsElement PlusButton => session.TryFindElementByAccessibilityId("plusButton");
|
||||
public WindowsElement EqualButton => session.TryFindElementByAccessibilityId("equalButton");
|
||||
public WindowsElement ClearEntryButton => session.TryFindElementByAccessibilityId("clearEntryButton");
|
||||
public WindowsElement ClearButton => session.TryFindElementByAccessibilityId("clearButton");
|
||||
public WindowsElement BackSpaceButton => session.TryFindElementByAccessibilityId("backSpaceButton");
|
||||
|
||||
/// <summary>
|
||||
/// Uses the Calculator UI to add a list of numbers.
|
||||
/// </summary>
|
||||
/// <param name="numbers">List of numbers to be added.</param>
|
||||
public void Add(List<double> numbers)
|
||||
{
|
||||
for (int i = 0; i < numbers.Count; i++)
|
||||
{
|
||||
NumberPad.TranslateNumberToButtonClicks(numbers[i]);
|
||||
|
||||
if (i != numbers.Count - 1)
|
||||
{
|
||||
PlusButton.Click();
|
||||
}
|
||||
else
|
||||
{
|
||||
EqualButton.Click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the Calculator UI to subtract a list of numbers.
|
||||
/// </summary>
|
||||
/// <param name="numbers">List of numbers to be subtracted.</param>
|
||||
public void Subtract(List<double> numbers)
|
||||
{
|
||||
for (int i = 0; i < numbers.Count; i++)
|
||||
{
|
||||
NumberPad.TranslateNumberToButtonClicks(numbers[i]);
|
||||
|
||||
if (i != numbers.Count - 1)
|
||||
{
|
||||
MinusButton.Click();
|
||||
}
|
||||
else
|
||||
{
|
||||
EqualButton.Click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the Calculator UI to multiply a list of numbers.
|
||||
/// </summary>
|
||||
/// <param name="numbers">List of numbers to be multiplied.</param>
|
||||
public void Multiply(List<double> numbers)
|
||||
{
|
||||
for (int i = 0; i < numbers.Count; i++)
|
||||
{
|
||||
NumberPad.TranslateNumberToButtonClicks(numbers[i]);
|
||||
|
||||
if (i != numbers.Count - 1)
|
||||
{
|
||||
MultiplyButton.Click();
|
||||
}
|
||||
else
|
||||
{
|
||||
EqualButton.Click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the Calculator UI to divide a list of numbers.
|
||||
/// </summary>
|
||||
/// <param name="numbers">List of numbers to be divided.</param>
|
||||
public void Divide(List<double> numbers)
|
||||
{
|
||||
for (int i = 0; i < numbers.Count; i++)
|
||||
{
|
||||
NumberPad.TranslateNumberToButtonClicks(numbers[i]);
|
||||
|
||||
if (i != numbers.Count - 1)
|
||||
{
|
||||
DivideButton.Click();
|
||||
}
|
||||
else
|
||||
{
|
||||
EqualButton.Click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the Calculator UI to take the reciprocal of a number.
|
||||
/// </summary>
|
||||
/// <param name="number">Number to take the reciprocal of.</param>
|
||||
public void Reciprocal(double number)
|
||||
{
|
||||
NumberPad.TranslateNumberToButtonClicks(number);
|
||||
InvertButton.Click();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the Calculator UI to square a number.
|
||||
/// </summary>
|
||||
/// <param name="number">The number to be squared.</param>
|
||||
public void Square(double number)
|
||||
{
|
||||
NumberPad.TranslateNumberToButtonClicks(number);
|
||||
XPower2Button.Click();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the Calculator UI to cube a number.
|
||||
/// </summary>
|
||||
/// <param name="number">The number to be cubed.</param>
|
||||
public void Cube(double number)
|
||||
{
|
||||
NumberPad.TranslateNumberToButtonClicks(number);
|
||||
XPower3Button.Click();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uses the Calculator UI to take the square root of a number.
|
||||
/// </summary>
|
||||
/// <param name="number">Number to take the square root of.</param>
|
||||
public void SquareRoot(double number)
|
||||
{
|
||||
NumberPad.TranslateNumberToButtonClicks(number);
|
||||
SquareRootButton.Click();
|
||||
}
|
||||
public WindowsElement PercentButton => this.session.TryFindElementByAccessibilityId("percentButton");
|
||||
public WindowsElement SquareRootButton => this.session.TryFindElementByAccessibilityId("squareRootButton");
|
||||
public WindowsElement XPower2Button => this.session.TryFindElementByAccessibilityId("xpower2Button");
|
||||
public WindowsElement XPower3Button => this.session.TryFindElementByAccessibilityId("xpower3Button");
|
||||
public WindowsElement InvertButton => this.session.TryFindElementByAccessibilityId("invertButton");
|
||||
public WindowsElement DivideButton => this.session.TryFindElementByAccessibilityId("divideButton");
|
||||
public WindowsElement MultiplyButton => this.session.TryFindElementByAccessibilityId("multiplyButton");
|
||||
public WindowsElement MinusButton => this.session.TryFindElementByAccessibilityId("minusButton");
|
||||
public WindowsElement PlusButton => this.session.TryFindElementByAccessibilityId("plusButton");
|
||||
public WindowsElement EqualButton => this.session.TryFindElementByAccessibilityId("equalButton");
|
||||
public WindowsElement ClearEntryButton => this.session.TryFindElementByAccessibilityId("clearEntryButton");
|
||||
public WindowsElement ClearButton => this.session.TryFindElementByAccessibilityId("clearButton");
|
||||
public WindowsElement BackSpaceButton => this.session.TryFindElementByAccessibilityId("backSpaceButton");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
|
@ -36,9 +36,9 @@ namespace CalculatorUITestFramework
|
|||
|
||||
public void SetupCalculatorSession(TestContext context)
|
||||
{
|
||||
windowsDriverService = new WindowsDriverServiceBuilder().Build();
|
||||
this.windowsDriverService = new WindowsDriverServiceBuilder().Build();
|
||||
|
||||
windowsDriverService.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
|
||||
this.windowsDriverService.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
|
||||
{
|
||||
if (!String.IsNullOrEmpty(e.Data))
|
||||
{
|
||||
|
@ -46,35 +46,35 @@ namespace CalculatorUITestFramework
|
|||
}
|
||||
});
|
||||
|
||||
windowsDriverService.Start();
|
||||
this.windowsDriverService.Start();
|
||||
|
||||
// Launch Calculator application if it is not yet launched
|
||||
if (CalculatorSession == null)
|
||||
if (this.CalculatorSession == null)
|
||||
{
|
||||
// Create a new WinAppDriver session to bring up an instance of the Calculator application
|
||||
// Note: Multiple calculator windows (instances) share the same process Id
|
||||
var options = new AppiumOptions();
|
||||
options.AddAdditionalCapability("app", calculatorAppId);
|
||||
options.AddAdditionalCapability("deviceName", "WindowsPC");
|
||||
CalculatorSession = new WindowsDriver<WindowsElement>(windowsDriverService.ServiceUrl, options);
|
||||
CalculatorSession.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
|
||||
Assert.IsNotNull(CalculatorSession);
|
||||
this.CalculatorSession = new WindowsDriver<WindowsElement>(this.windowsDriverService.ServiceUrl, options);
|
||||
this.CalculatorSession.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
|
||||
Assert.IsNotNull(this.CalculatorSession);
|
||||
}
|
||||
}
|
||||
|
||||
public void TearDownCalculatorSession()
|
||||
{
|
||||
// Close the application and delete the session
|
||||
if (CalculatorSession != null)
|
||||
if (this.CalculatorSession != null)
|
||||
{
|
||||
CalculatorSession.Quit();
|
||||
CalculatorSession = null;
|
||||
this.CalculatorSession.Quit();
|
||||
this.CalculatorSession = null;
|
||||
}
|
||||
|
||||
if (windowsDriverService != null)
|
||||
if (this.windowsDriverService != null)
|
||||
{
|
||||
windowsDriverService.Dispose();
|
||||
windowsDriverService = null;
|
||||
this.windowsDriverService.Dispose();
|
||||
this.windowsDriverService = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
using OpenQA.Selenium.Appium.Service;
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//See the NOTICE file distributed with this work for additional
|
||||
//information regarding copyright ownership.
|
||||
//You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
|
||||
//Portions Copyright (c) Microsoft Corporation
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
|
@ -27,33 +40,33 @@ namespace CalculatorUITestFramework
|
|||
int port,
|
||||
TimeSpan initializationTimeout)
|
||||
{
|
||||
FileName = fileName;
|
||||
Arguments = arguments;
|
||||
IP = ip;
|
||||
Port = port;
|
||||
InitializationTimeout = initializationTimeout;
|
||||
this.FileName = fileName;
|
||||
this.Arguments = arguments;
|
||||
this.IP = ip;
|
||||
this.Port = port;
|
||||
this.InitializationTimeout = initializationTimeout;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
public void Start()
|
||||
{
|
||||
if (IsRunning)
|
||||
if (this.IsRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Service = new Process();
|
||||
Service.StartInfo.FileName = FileName.FullName;
|
||||
Service.StartInfo.Arguments = Arguments;
|
||||
Service.StartInfo.UseShellExecute = false;
|
||||
Service.StartInfo.CreateNoWindow = true;
|
||||
this.Service = new Process();
|
||||
this.Service.StartInfo.FileName = FileName.FullName;
|
||||
this.Service.StartInfo.Arguments = Arguments;
|
||||
this.Service.StartInfo.UseShellExecute = false;
|
||||
this.Service.StartInfo.CreateNoWindow = true;
|
||||
|
||||
Service.StartInfo.RedirectStandardOutput = true;
|
||||
Service.OutputDataReceived += (sender, e) => OutputDataReceived?.Invoke(this, e);
|
||||
this.Service.StartInfo.RedirectStandardOutput = true;
|
||||
this.Service.OutputDataReceived += (sender, e) => OutputDataReceived?.Invoke(this, e);
|
||||
|
||||
bool isLaunched = false;
|
||||
string msgTxt =
|
||||
$"The local WinAppDriver server has not been started: {FileName.FullName} Arguments: {Arguments}. " +
|
||||
$"The local WinAppDriver server has not been started: {this.FileName.FullName} Arguments: {this.Arguments}. " +
|
||||
"\n";
|
||||
|
||||
try
|
||||
|
@ -82,14 +95,14 @@ namespace CalculatorUITestFramework
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Service == null)
|
||||
if (this.Service == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var pid = Service.Id;
|
||||
var pid = this.Service.Id;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -109,26 +122,26 @@ namespace CalculatorUITestFramework
|
|||
public Uri ServiceUrl
|
||||
{
|
||||
// Note: append /wd/hub to the URL if you're directing the test at Appium
|
||||
get { return new Uri($"http://{IP.ToString()}:{Convert.ToString(Port)}"); }
|
||||
get { return new Uri($"http://{this.IP.ToString()}:{Convert.ToString(this.Port)}"); }
|
||||
}
|
||||
|
||||
private void DestroyProcess()
|
||||
{
|
||||
if (Service == null)
|
||||
if (this.Service == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Service.Kill();
|
||||
this.Service.Kill();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
Service.Close();
|
||||
this.Service.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,10 +151,10 @@ namespace CalculatorUITestFramework
|
|||
|
||||
Uri status;
|
||||
|
||||
Uri service = ServiceUrl;
|
||||
Uri service = this.ServiceUrl;
|
||||
if (service.IsLoopback)
|
||||
{
|
||||
status = new Uri("http://localhost:" + Convert.ToString(Port) + "/status");
|
||||
status = new Uri("http://localhost:" + Convert.ToString(this.Port) + "/status");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium.Service;
|
||||
using OpenQA.Selenium.Appium.Service.Options;
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//See the NOTICE file distributed with this work for additional
|
||||
//information regarding copyright ownership.
|
||||
//You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
|
||||
//Portions Copyright(c) Microsoft Corporation
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
{
|
||||
|
@ -20,11 +30,11 @@ namespace CalculatorUITestFramework
|
|||
|
||||
public WindowsDriverLocalService Build()
|
||||
{
|
||||
if (FileInfo == null)
|
||||
if (this.FileInfo == null)
|
||||
{
|
||||
FileInfo = new FileInfo(@"c:\Program Files (x86)\Windows Application Driver\winappdriver.exe");
|
||||
this.FileInfo = new FileInfo(@"c:\Program Files (x86)\Windows Application Driver\winappdriver.exe");
|
||||
}
|
||||
return new WindowsDriverLocalService(FileInfo, string.Empty, IPAddress.Parse(this.IpAddress), this.Port, StartUpTimeout);
|
||||
return new WindowsDriverLocalService(this.FileInfo, string.Empty, IPAddress.Parse(this.IpAddress), this.Port, this.StartUpTimeout);
|
||||
}
|
||||
|
||||
public WindowsDriverServiceBuilder WithFileInfo(FileInfo fileInfo)
|
||||
|
@ -33,7 +43,7 @@ namespace CalculatorUITestFramework
|
|||
{
|
||||
throw new ArgumentNullException("FileInfo should not be NULL");
|
||||
}
|
||||
FileInfo = fileInfo;
|
||||
this.FileInfo = fileInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -43,13 +53,13 @@ namespace CalculatorUITestFramework
|
|||
{
|
||||
throw new ArgumentNullException("A startup timeout should not be NULL");
|
||||
}
|
||||
StartUpTimeout = startUpTimeout;
|
||||
this.StartUpTimeout = startUpTimeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WindowsDriverServiceBuilder WithIPAddress(string ipAddress)
|
||||
{
|
||||
IpAddress = ipAddress;
|
||||
this.IpAddress = ipAddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -65,7 +75,7 @@ namespace CalculatorUITestFramework
|
|||
return UsingAnyFreePort();
|
||||
}
|
||||
|
||||
Port = port;
|
||||
this.Port = port;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -78,7 +88,7 @@ namespace CalculatorUITestFramework
|
|||
sock = new Socket(AddressFamily.InterNetwork,
|
||||
SocketType.Stream, ProtocolType.Tcp);
|
||||
sock.Bind(new IPEndPoint(IPAddress.Any, 0));
|
||||
Port = ((IPEndPoint)sock.LocalEndPoint).Port;
|
||||
this.Port = ((IPEndPoint)sock.LocalEndPoint).Port;
|
||||
return this;
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace CalculatorUITestFramework
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
using CalculatorUITestFramework;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Remote;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace CalculatorUITests
|
||||
{
|
||||
|
@ -56,8 +54,10 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void SmokeTest_Add()
|
||||
{
|
||||
// Find the buttons by their names and click them in sequence to peform 1 + 7 = 8
|
||||
page.StandardOperators.Add(new List<double>() { 3.5, 0.25 });
|
||||
page.StandardOperators.NumberPad.Input(3.5);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(0.25);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("3.75", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
|
@ -71,17 +71,31 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void SmokeTest_Subtract()
|
||||
{
|
||||
// Find the buttons by their names and click them in sequence to peform 1 + 7 = 8
|
||||
page.StandardOperators.Subtract(new List<double>() { 4.3, 2.6 });
|
||||
page.StandardOperators.NumberPad.Input(4.3);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(2.6);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("1.7", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SmokeTest_History()
|
||||
{
|
||||
page.StandardOperators.Add(new List<double>() { -3, -2.6 });
|
||||
page.StandardOperators.Subtract(new List<double>() { 2, 3 });
|
||||
page.StandardOperators.Multiply(new List<double>() { 1, 3 });
|
||||
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));
|
||||
|
@ -92,12 +106,24 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void SmokeTest_Memory()
|
||||
{
|
||||
page.StandardOperators.Add(new List<double>() { 3, 0 });
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(0);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
page.StandardOperators.Divide(new List<double>() { 2, 3 });
|
||||
|
||||
page.StandardOperators.NumberPad.Input(2);
|
||||
page.StandardOperators.DivideButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(3);
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
page.MemoryPanel.MemButton.Click();
|
||||
page.StandardOperators.Multiply(new List<double>() { 7, 9 });
|
||||
|
||||
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));
|
||||
|
@ -113,37 +139,41 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void Operator_Reciprocal()
|
||||
{
|
||||
page.StandardOperators.Reciprocal(4);
|
||||
page.StandardOperators.NumberPad.Input(4);
|
||||
page.StandardOperators.InvertButton.Click();
|
||||
Assert.AreEqual("0.25", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operator_Squared()
|
||||
{
|
||||
page.StandardOperators.Square(-15.5);
|
||||
page.StandardOperators.NumberPad.Input(-15.5);
|
||||
page.StandardOperators.XPower2Button.Click();
|
||||
Assert.AreEqual("240.25", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operator_SquareRoot()
|
||||
{
|
||||
page.StandardOperators.SquareRoot(144);
|
||||
page.StandardOperators.NumberPad.Input(144);
|
||||
page.StandardOperators.SquareRootButton.Click();
|
||||
Assert.AreEqual("12", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operator_Cubed()
|
||||
{
|
||||
page.StandardOperators.Cube(-3);
|
||||
page.StandardOperators.NumberPad.Input(-3);
|
||||
page.StandardOperators.XPower3Button.Click();
|
||||
Assert.AreEqual("-27", page.GetCalculatorResultText());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Operator_Percent()
|
||||
{
|
||||
page.StandardOperators.NumberPad.TranslateNumberToButtonClicks(600);
|
||||
page.StandardOperators.NumberPad.Input(600);
|
||||
page.StandardOperators.MultiplyButton.Click();
|
||||
page.StandardOperators.NumberPad.TranslateNumberToButtonClicks(15);
|
||||
page.StandardOperators.NumberPad.Input(15);
|
||||
page.StandardOperators.PercentButton.Click();
|
||||
page.StandardOperators.EqualButton.Click();
|
||||
Assert.AreEqual("90", page.GetCalculatorResultText());
|
||||
|
@ -152,7 +182,7 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void Operator_Delete()
|
||||
{
|
||||
page.StandardOperators.NumberPad.TranslateNumberToButtonClicks(-12345);
|
||||
page.StandardOperators.NumberPad.Input(-12345);
|
||||
page.StandardOperators.BackSpaceButton.Click();
|
||||
Assert.AreEqual("-1,234", page.GetCalculatorResultText());
|
||||
}
|
||||
|
@ -160,7 +190,9 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void Operator_ClearAll()
|
||||
{
|
||||
page.StandardOperators.Add(new List<double>() { 12345, 6789 });
|
||||
page.StandardOperators.NumberPad.Input(12345);
|
||||
page.StandardOperators.PlusButton.Click();
|
||||
page.StandardOperators.NumberPad.Input(6789);
|
||||
page.StandardOperators.ClearButton.Click();
|
||||
Assert.AreEqual("0", page.GetCalculatorResultText());
|
||||
}
|
||||
|
@ -168,9 +200,9 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void Operator_ClearEntry()
|
||||
{
|
||||
page.StandardOperators.NumberPad.TranslateNumberToButtonClicks(-12345);
|
||||
page.StandardOperators.NumberPad.Input(-12345);
|
||||
page.StandardOperators.MinusButton.Click();
|
||||
page.StandardOperators.NumberPad.TranslateNumberToButtonClicks(5678);
|
||||
page.StandardOperators.NumberPad.Input(5678);
|
||||
page.StandardOperators.ClearEntryButton.Click();
|
||||
Assert.AreEqual("0", page.GetCalculatorResultText());
|
||||
}
|
||||
|
@ -239,9 +271,13 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void Memory_AddTest()
|
||||
{
|
||||
page.StandardOperators.Divide(new List<double>() { 12, 3 });
|
||||
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.TranslateNumberToButtonClicks(15);
|
||||
page.StandardOperators.NumberPad.Input(15);
|
||||
page.MemoryPanel.MemPlus.Click();
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("19", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
@ -250,9 +286,13 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void Memory_SubtractTest()
|
||||
{
|
||||
page.StandardOperators.Divide(new List<double>() { 12, 3 });
|
||||
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.TranslateNumberToButtonClicks(3.3);
|
||||
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));
|
||||
|
@ -261,9 +301,13 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void Memory_RecallTest()
|
||||
{
|
||||
page.StandardOperators.Divide(new List<double>() { 12, 3 });
|
||||
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.TranslateNumberToButtonClicks(3.3);
|
||||
page.StandardOperators.NumberPad.Input(3.3);
|
||||
page.MemoryPanel.MemRecall.Click();
|
||||
var memoryItems = page.MemoryPanel.GetAllMemoryListViewItems();
|
||||
Assert.IsTrue(memoryItems[0].Text.Equals("4", StringComparison.InvariantCultureIgnoreCase));
|
||||
|
@ -272,9 +316,13 @@ namespace CalculatorUITests
|
|||
[TestMethod]
|
||||
public void Memory_ClearTest()
|
||||
{
|
||||
page.StandardOperators.Divide(new List<double>() { 12, 3 });
|
||||
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.TranslateNumberToButtonClicks(3.3);
|
||||
page.StandardOperators.NumberPad.Input(3.3);
|
||||
page.MemoryPanel.MemoryClear.Click();
|
||||
page.MemoryPanel.OpenMemoryPanel();
|
||||
Assert.IsNotNull(page.MemoryPanel.MemoryPaneEmptyLabel);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue