Skip to content

Commit 34686ae

Browse files
authored
[Visual Testing] Add ability of visualization checks for the Screen (#31) +semver: breaking
* [Visual Testing] Add ability of visualization checks for the Screen +semver: breaking * update Aquality.Selenium.Core to latest version * make Screen inherit the Form<IElement>, implement abstractions * Add visualization settings block to settings.json Add SaveAndCompareScreenDump test to ensure that visualization feature works correctly * Install runtime.osx.10.10-x64.CoreCompat.System.Drawing to run tests on MacOS
1 parent 9fb6340 commit 34686ae

File tree

12 files changed

+155
-23
lines changed

12 files changed

+155
-23
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ msbuild.wrn
3737
.vs/
3838

3939
Log/
40+
VisualDumps/

Aquality.Appium.Mobile/src/Aquality.Appium.Mobile/Aquality.Appium.Mobile.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
<ItemGroup>
4848
<PackageReference Include="Appium.WebDriver" Version="4.3.1" />
49-
<PackageReference Include="Aquality.Selenium.Core" Version="1.3.1" />
49+
<PackageReference Include="Aquality.Selenium.Core" Version="1.6.1" />
5050
</ItemGroup>
5151

5252
</Project>

Aquality.Appium.Mobile/src/Aquality.Appium.Mobile/Aquality.Appium.Mobile.xml

Lines changed: 97 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Aquality.Appium.Mobile/src/Aquality.Appium.Mobile/Elements/Element.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Aquality.Selenium.Core.Elements.Interfaces;
77
using Aquality.Selenium.Core.Localization;
88
using Aquality.Selenium.Core.Utilities;
9+
using Aquality.Selenium.Core.Visualization;
910
using Aquality.Selenium.Core.Waitings;
1011
using OpenQA.Selenium;
1112
using OpenQA.Selenium.Appium;
@@ -36,6 +37,8 @@ protected Element(By locator, string name, ElementState state) : base(locator, n
3637

3738
protected override IElementFinder Finder => AqualityServices.Get<IElementFinder>();
3839

40+
protected override IImageComparator ImageComparator => AqualityServices.Get<IImageComparator>();
41+
3942
protected override ILocalizedLogger LocalizedLogger => AqualityServices.LocalizedLogger;
4043

4144
protected override ILocalizationManager LocalizationManager => AqualityServices.Get<ILocalizationManager>();

Aquality.Appium.Mobile/src/Aquality.Appium.Mobile/Resources/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,11 @@
5353
"verticalOffset": 0.2,
5454
"horizontalOffset": 0.5
5555
}
56+
},
57+
"visualization": {
58+
"defaultThreshold": 0.012,
59+
"comparisonWidth": 16,
60+
"comparisonHeight": 16,
61+
"pathToDumps": "../../../Resources/VisualDumps/"
5662
}
5763
}

Aquality.Appium.Mobile/src/Aquality.Appium.Mobile/Screens/IScreen.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Aquality.Selenium.Core.Elements.Interfaces;
2+
using Aquality.Selenium.Core.Forms;
23
using OpenQA.Selenium;
34
using System.Drawing;
45

@@ -7,18 +8,13 @@ namespace Aquality.Appium.Mobile.Screens
78
/// <summary>
89
/// Interface that describes application under the test screen.
910
/// </summary>
10-
public interface IScreen
11+
public interface IScreen : IForm
1112
{
1213
/// <summary>
1314
/// Unique screen locator.
1415
/// </summary>
1516
By Locator { get; }
1617

17-
/// <summary>
18-
/// Unique screen name.
19-
/// </summary>
20-
string Name { get; }
21-
2218
/// <summary>
2319
/// Size of the element described by screen locator.
2420
/// </summary>

Aquality.Appium.Mobile/src/Aquality.Appium.Mobile/Screens/Screen.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using Aquality.Appium.Mobile.Applications;
22
using Aquality.Appium.Mobile.Elements.Interfaces;
3+
using Aquality.Selenium.Core.Configurations;
34
using Aquality.Selenium.Core.Elements.Interfaces;
5+
using Aquality.Selenium.Core.Forms;
6+
using Aquality.Selenium.Core.Localization;
47
using OpenQA.Selenium;
58
using System.Drawing;
69
using IElement = Aquality.Appium.Mobile.Elements.Interfaces.IElement;
@@ -13,7 +16,7 @@ namespace Aquality.Appium.Mobile.Screens
1316
/// Use <see cref="ScreenFactory.ScreenTypeAttribute"/> on your screen class to identify platform.
1417
/// <seealso cref="ScreenFactory.ScreenFactory"/>
1518
/// </summary>
16-
public abstract class Screen : IScreen
19+
public abstract class Screen : Form<IElement>, IScreen
1720
{
1821
private readonly ILabel screenLabel;
1922

@@ -39,7 +42,11 @@ protected Screen(By locator, string name)
3942
/// Element factory <see cref="IElementFactory"/>
4043
/// </summary>
4144
protected static IElementFactory ElementFactory => AqualityServices.ElementFactory;
42-
45+
46+
protected override IVisualizationConfiguration VisualizationConfiguration => AqualityServices.Get<IVisualizationConfiguration>();
47+
48+
protected override ILocalizedLogger LocalizedLogger => AqualityServices.LocalizedLogger;
49+
4350
/// <summary>
4451
/// Locator of the screen.
4552
/// </summary>
@@ -48,12 +55,12 @@ protected Screen(By locator, string name)
4855
/// <summary>
4956
/// Name of the screen.
5057
/// </summary>
51-
public string Name { get; }
58+
public override string Name { get; }
5259

5360
/// <summary>
5461
/// Gets size of form element defined by its locator.
5562
/// </summary>
56-
public Size Size => screenLabel.GetElement().Size;
63+
public Size Size => screenLabel.Visual.Size;
5764

5865
/// <summary>
5966
/// Provides ability to get screen's state (whether it is displayed, exists or not) and respective waiting functions.

Aquality.Appium.Mobile/tests/Aquality.Appium.Mobile.Tests/Aquality.Appium.Mobile.Tests.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="nunit" Version="3.13.1" />
11-
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
10+
<PackageReference Include="nunit" Version="3.13.2" />
11+
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0">
1212
<PrivateAssets>all</PrivateAssets>
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
</PackageReference>
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
16+
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="5.8.64" />
1617
</ItemGroup>
1718

1819
<ItemGroup>

Aquality.Appium.Mobile/tests/Aquality.Appium.Mobile.Tests/Resources/settings.androidwebsession.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,11 @@
4444
"verticalOffset": 0.2,
4545
"horizontalOffset": 0.5
4646
}
47+
},
48+
"visualization": {
49+
"defaultThreshold": 0.012,
50+
"comparisonWidth": 16,
51+
"comparisonHeight": 16,
52+
"pathToDumps": "../../../Resources/VisualDumps/"
4753
}
4854
}

Aquality.Appium.Mobile/tests/Aquality.Appium.Mobile.Tests/Resources/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,11 @@
5555
"verticalOffset": 0.2,
5656
"horizontalOffset": 0.5
5757
}
58+
},
59+
"visualization": {
60+
"defaultThreshold": 0.012,
61+
"comparisonWidth": 16,
62+
"comparisonHeight": 16,
63+
"pathToDumps": "../../../Resources/VisualDumps/"
5864
}
5965
}

0 commit comments

Comments
 (0)