-
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.
* added tests for IElement * fixed element type * started implementing tests for IElementStateProvider * implemented IElementStateProvider tests * renamed test * implemented tests for public properties * added tests * refactored test methods * fixed test name * fixed test. added Should_ReturnCorrectElementType(), moved TestWindow class * moved property in class
- Loading branch information
Showing
2 changed files
with
84 additions
and
7 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Windows/TestWindow.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,14 @@ | ||
using Aquality.WinAppDriver.Windows; | ||
using OpenQA.Selenium; | ||
|
||
namespace Aquality.WinAppDriver.Tests.Windows | ||
{ | ||
public class TestWindow : Window | ||
{ | ||
public TestWindow(By locator, string name) : base(locator, name) | ||
{ | ||
} | ||
|
||
public new string ElementType => base.ElementType; | ||
} | ||
} |
77 changes: 70 additions & 7 deletions
77
Aquality.WinAppDriver/tests/Aquality.WinAppDriver.Tests/Windows/WindowTests.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,19 +1,82 @@ | ||
using NUnit.Framework; | ||
using OpenQA.Selenium; | ||
|
||
namespace Aquality.WinAppDriver.Tests.Windows | ||
{ | ||
public class WindowTests : TestWithApplication | ||
{ | ||
private static readonly CalculatorWindowWithRelativeElements calculatorWindow = new CalculatorWindowWithRelativeElements(); | ||
private const int ExpectedHeight = 500; | ||
private const int ExpectedWidth = 709; | ||
private static readonly By Locator = By.XPath("//*[@id='111111']"); | ||
private const string PageName = "Not present page"; | ||
private const string ExpectedElementType = "Акно"; | ||
|
||
private static readonly CalculatorWindowWithRelativeElements CalculatorWindowWithRelativeElements = | ||
new CalculatorWindowWithRelativeElements(); | ||
|
||
private static readonly CalculatorWindow CalculatorWindow = new CalculatorWindow(); | ||
|
||
private static TestWindow TestWindow => new TestWindow(Locator, PageName); | ||
|
||
[Test] | ||
public void Should_WorkWithCalculator_ViaRelativeElements() | ||
{ | ||
calculatorWindow.OneButton.Click(); | ||
calculatorWindow.PlusButton.Click(); | ||
calculatorWindow.TwoButton.Click(); | ||
calculatorWindow.EqualsButton.Click(); | ||
StringAssert.Contains("3", calculatorWindow.ResultsLabel.Text); | ||
CalculatorWindowWithRelativeElements.OneButton.Click(); | ||
CalculatorWindowWithRelativeElements.PlusButton.Click(); | ||
CalculatorWindowWithRelativeElements.TwoButton.Click(); | ||
CalculatorWindowWithRelativeElements.EqualsButton.Click(); | ||
StringAssert.Contains("3", CalculatorWindowWithRelativeElements.ResultsLabel.Text); | ||
} | ||
|
||
[Test] | ||
public void Should_GetSizeCorrectly_WhenWindowIsPresent() | ||
{ | ||
var windowSize = CalculatorWindow.Size; | ||
Assert.Multiple(() => | ||
{ | ||
Assert.IsFalse(windowSize.IsEmpty, "Window is not empty"); | ||
Assert.AreEqual(ExpectedHeight, windowSize.Height, "Height"); | ||
Assert.AreEqual(ExpectedWidth, windowSize.Width, "Width"); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void Should_ThrowException_InGetSize_WhenWindowIsNotPresent() | ||
{ | ||
Assert.Throws<NoSuchElementException>(() => | ||
{ | ||
var testWindowSize = TestWindow.Size; | ||
}); | ||
} | ||
|
||
[Test] | ||
public void Should_ReturnTrue_IfWindowIsDisplayed() | ||
{ | ||
Assert.IsTrue(CalculatorWindow.IsDisplayed); | ||
} | ||
|
||
[Test] | ||
public void Should_ReturnFalse_IfWindowIsNotDisplayed() | ||
{ | ||
Assert.IsFalse(TestWindow.IsDisplayed); | ||
} | ||
|
||
[Test] | ||
public void Should_SetCorrectLocatorInConstructor() | ||
{ | ||
Assert.AreEqual(Locator, TestWindow.Locator, "Locator"); | ||
} | ||
|
||
[Test] | ||
public void Should_SetCorrectPageNameInConstructor() | ||
{ | ||
Assert.AreEqual(PageName, TestWindow.Name, "Name"); | ||
} | ||
|
||
[Test] | ||
public void Should_ReturnCorrectElementType() | ||
{ | ||
Assert.AreEqual(ExpectedElementType, TestWindow.ElementType); | ||
} | ||
} | ||
} | ||
} |