-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented tests for ITextBox interface
- Loading branch information
Showing
5 changed files
with
81 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 18 additions & 10 deletions
28
....WinAppDriver/tests/Aquality.WinAppDriver.Tests/Applications/Locators/CalculatorWindow.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
using OpenQA.Selenium; | ||
using Aquality.WinAppDriver.Elements.Interfaces; | ||
using Aquality.WinAppDriver.Windows; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Appium; | ||
|
||
namespace Aquality.WinAppDriver.Tests.Applications.Locators | ||
{ | ||
public static class CalculatorWindow | ||
public class CalculatorWindow : Window | ||
{ | ||
public static By WindowLocator => By.TagName("Window"); | ||
private static By WindowLocator => By.TagName("Window"); | ||
|
||
public static By OneButton => By.Name("1"); | ||
public ITextBox RightArgumentTextBox => ElementFactory.GetTextBox(By.XPath("//*[@AutomationId='49']"), "Right Argument"); | ||
|
||
public static By TwoButton => By.Name("2"); | ||
public IButton OneButton => ElementFactory.GetButton(By.Name("1"), "1"); | ||
|
||
public static By ThreeButton => By.Name("3"); | ||
public IButton TwoButton => ElementFactory.GetButton(By.Name("2"), "2"); | ||
|
||
public static By PlusButton => By.Name("+"); | ||
public IButton PlusButton => ElementFactory.GetButton(By.Name("+"), "+"); | ||
|
||
public static By EqualsButton => By.Name("="); | ||
public IButton EqualsButton => ElementFactory.GetButton(By.Name("="), "="); | ||
|
||
public static By ResultsLabel => MobileBy.AccessibilityId("48"); | ||
public ILabel ResultsLabel => ElementFactory.GetLabel(MobileBy.AccessibilityId("48"), "Results bar"); | ||
|
||
public IElement NumberPad => ElementFactory.GetButton(WindowLocator, "Number pad"); | ||
|
||
public CalculatorWindow() : base(WindowLocator, "Main Calculator Window") | ||
{ | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Elements/TextBoxTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Aquality.WinAppDriver.Elements.Interfaces; | ||
using Aquality.WinAppDriver.Tests.Applications.Locators; | ||
using NUnit.Framework; | ||
|
||
namespace Aquality.WinAppDriver.Tests.Elements | ||
{ | ||
public class TextBoxTests : TestWithApplication | ||
{ | ||
private const string ExpectedValue = "1"; | ||
private readonly ITextBox rightArgumentTextBox = new CalculatorWindow().RightArgumentTextBox; | ||
|
||
[Test] | ||
public void Should_EnterValues() | ||
{ | ||
rightArgumentTextBox.Type(ExpectedValue); | ||
Assert.AreEqual(ExpectedValue, rightArgumentTextBox.Value); | ||
} | ||
|
||
[Test] | ||
public void Should_EnterValues_WithoutCleaningTextbox() | ||
{ | ||
rightArgumentTextBox.Type(ExpectedValue); | ||
const string additionalExpectedValue = "23"; | ||
rightArgumentTextBox.Type(additionalExpectedValue); | ||
Assert.AreEqual(ExpectedValue + additionalExpectedValue, rightArgumentTextBox.Value); | ||
} | ||
|
||
[Test] | ||
public void Should_ClearTextBeforeEnteringValues_PrefilledTextbox() | ||
{ | ||
rightArgumentTextBox.Type("123"); | ||
rightArgumentTextBox.ClearAndType(ExpectedValue); | ||
Assert.AreEqual(ExpectedValue, rightArgumentTextBox.Value); | ||
} | ||
|
||
[Test] | ||
public void Should_ClearTextBeforeEnteringValues_EmptyTextbox() | ||
{ | ||
rightArgumentTextBox.ClearAndType(ExpectedValue); | ||
Assert.AreEqual(ExpectedValue, rightArgumentTextBox.Value); | ||
} | ||
} | ||
} |