* Fixes issue #1409

Copy pasting into Currency locks the editor.
Skipping the validation of full editor lock when backspace or clear button is clicked.

* Adding code review feedback.

* Adding code review feedback.
This commit is contained in:
Bura Chuhadar
2020-11-10 12:56:39 -05:00
committed by GitHub
parent 15ae66626a
commit 483dacbeff
6 changed files with 306 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
// 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.Text;
namespace CalculatorUITestFramework
{
public class UnitConverterOperatorsPanel
{
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
public NumberPad NumberPad = new NumberPad();
public WindowsElement ClearButton => this.session.TryFindElementByAccessibilityId("ClearEntryButtonPos0");
public WindowsElement BackSpaceButton => this.session.TryFindElementByAccessibilityId("BackSpaceButtonSmall");
}
}

View File

@@ -0,0 +1,68 @@
// 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.Text;
namespace CalculatorUITestFramework
{
public class UnitConverterPage
{
public UnitConverterOperatorsPanel UnitConverterOperators = new UnitConverterOperatorsPanel();
public NavigationMenu NavigationMenu = new NavigationMenu();
public UnitConverterResults UnitConverterResults = new UnitConverterResults();
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
/// <summary>
/// Clear the Calculator display
/// </summary>
public void ClearAll()
{
this.UnitConverterOperators.ClearButton.Click();
}
///// <summary>
///// Ensures that the calculator result text is zero; if not, clears all
///// </summary>
public void EnsureCalculatorResultTextIsZero()
{
if ("0" != this.UnitConverterResults.GetCalculationResult1Text())
{
this.ClearAll();
}
}
/// <summary>
/// Navigates the calculator is in currency mode
/// </summary>
public void NavigateToUnitConverter()
{
// Ensure that calculator is in Currency Mode
this.NavigationMenu.ChangeCalculatorMode(CalculatorMode.Currency);
this.UnitConverterResults.IsResultsDisplayPresent();
}
///// <summary>
///// Ensures that the calculator is in Currency Mode
///// </summary>
public void EnsureCalculatorIsCurrencyMode()
{
string source = WinAppDriver.Instance.CalculatorSession.PageSource;
if (source.Contains("Header"))
{
string header = CalculatorApp.Header.Text;
if (header == "Currency")
{
return;
}
else
{
this.NavigateToUnitConverter();
}
}
}
}
}

View File

@@ -0,0 +1,47 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;
using System;
using OpenQA.Selenium.Interactions;
using System.Text.RegularExpressions;
namespace CalculatorUITestFramework
{
public class UnitConverterResults
{
private WindowsDriver<WindowsElement> session => WinAppDriver.Instance.CalculatorSession;
private WindowsElement CalculationResult1 => this.session.TryFindElementByAccessibilityId("Value1");
private WindowsElement CalculationResult2 => this.session.TryFindElementByAccessibilityId("Value2");
/// <summary>
/// Gets the text from the Value1 control and removes the narrator text that is not displayed in the UI.
/// </summary>
/// <returns>The string shown in the UI.</returns>
public string GetCalculationResult1Text()
{
return Regex.Replace(this.CalculationResult1.Text.Trim(), "[^0-9.]", "");
}
/// <summary>
/// Verifies that CalculationResult1 and CalculationResult2 are not null
/// </summary>
/// <returns>The string shown in the UI.</returns>
public void IsResultsDisplayPresent()
{
Assert.IsNotNull(this.CalculationResult1);
Assert.IsNotNull(this.CalculationResult2);
}
/// <summary>
/// Gets the text from the Value2 control and removes the narrator text that is not displayed in the UI.
/// </summary>
/// <returns>The string shown in the UI.</returns>
public string GetCalculationResult2Text()
{
return Regex.Replace(this.CalculationResult2.Text.Trim(), "[^0-9.]", "");
}
}
}