Skip to content

Commit be6fa7b

Browse files
authored
Update Aquality.Selenium.Core library version. (#191)
* Update Aquality.Selenium.Core library version. * Allow overriding of browser capabilities and options via environment variables. * Remove core library dependencies duplication. * Add documentation to form methods. * Mark some form methods and properties as obsolete with explanation what to use instead. * Replace LocalizationLogger with Logger property in form. * Make ElementFactory property in Form static in to make it possible to be used during the field initialization.
1 parent d0c1979 commit be6fa7b

File tree

6 files changed

+128
-34
lines changed

6 files changed

+128
-34
lines changed

Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@
6565
</ItemGroup>
6666

6767
<ItemGroup>
68-
<PackageReference Include="Aquality.Selenium.Core" Version="1.1.0" />
69-
<PackageReference Include="NLog" Version="4.7.0" />
70-
<PackageReference Include="Selenium.Support" Version="3.141.0" />
71-
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
68+
<PackageReference Include="Aquality.Selenium.Core" Version="1.1.1" />
7269
<PackageReference Include="WebDriverManager" Version="2.9.1" />
7370
</ItemGroup>
7471

Aquality.Selenium/src/Aquality.Selenium/Aquality.Selenium.xml

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

Aquality.Selenium/src/Aquality.Selenium/Configurations/WebDriverSettings/DriverSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public virtual string DownloadDir
5050

5151
public abstract string DownloadDirCapabilityKey { get; }
5252

53-
protected IDictionary<string, object> BrowserCapabilities => SettingsFile.GetValueOrNew<Dictionary<string, object>>($"{DriverSettingsPath}.capabilities");
53+
protected IReadOnlyDictionary<string, object> BrowserCapabilities => SettingsFile.GetValueDictionaryOrEmpty<object>($"{DriverSettingsPath}.capabilities");
5454

55-
protected IDictionary<string, object> BrowserOptions => SettingsFile.GetValueOrNew<Dictionary<string, object>>($"{DriverSettingsPath}.options");
55+
protected IReadOnlyDictionary<string, object> BrowserOptions => SettingsFile.GetValueDictionaryOrEmpty<object>($"{DriverSettingsPath}.options");
5656

5757
protected IReadOnlyList<string> BrowserStartArguments => SettingsFile.GetValueListOrEmpty<string>($"{DriverSettingsPath}.startArguments");
5858

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
using Aquality.Selenium.Elements.Interfaces;
2-
using OpenQA.Selenium;
1+
using System;
2+
using System.Collections.Generic;
33
using System.Drawing;
4-
using Aquality.Selenium.Browsers;
5-
using Aquality.Selenium.Core.Localization;
4+
using OpenQA.Selenium;
65
using Aquality.Selenium.Core.Elements;
7-
using System.Collections.Generic;
6+
using Aquality.Selenium.Core.Logging;
7+
using Aquality.Selenium.Browsers;
8+
using Aquality.Selenium.Elements.Interfaces;
9+
using IElementStateProvider = Aquality.Selenium.Core.Elements.Interfaces.IElementStateProvider;
810

911
namespace Aquality.Selenium.Forms
1012
{
@@ -13,6 +15,7 @@ namespace Aquality.Selenium.Forms
1315
/// </summary>
1416
public abstract class Form
1517
{
18+
private readonly ILabel formLabel;
1619
/// <summary>
1720
/// Constructor with parameters.
1821
/// </summary>
@@ -22,29 +25,32 @@ protected Form(By locator, string name)
2225
{
2326
Locator = locator;
2427
Name = name;
28+
formLabel = ElementFactory.GetLabel(Locator, Name);
2529
}
2630

27-
private ILabel FormLabel => ElementFactory.GetLabel(Locator, Name);
31+
/// <summary>
32+
/// Gets Form element defined by its locator and name.
33+
/// Could be used to find child elements relative to form element.
34+
/// </summary>
35+
protected IElement FormElement => formLabel;
2836

2937
/// <summary>
30-
/// Instance of logger <see cref="Logging.Logger">
38+
/// Instance of logger <see cref="Core.Logging.Logger"/>
3139
/// </summary>
32-
/// <value>Logger instance.</value>
33-
protected ILocalizedLogger Logger => AqualityServices.LocalizedLogger;
40+
protected static Logger Logger => AqualityServices.Logger;
3441

3542
/// <summary>
36-
/// Element factory <see cref="IElementFactory">
43+
/// Element factory <see cref="IElementFactory"/>
3744
/// </summary>
38-
/// <value>Element factory.</value>
39-
protected IElementFactory ElementFactory => AqualityServices.Get<IElementFactory>();
45+
protected static IElementFactory ElementFactory => AqualityServices.Get<IElementFactory>();
4046

4147
/// <summary>
42-
/// Locator of specified form.
48+
/// Locator of the form.
4349
/// </summary>
4450
public By Locator { get; }
4551

4652
/// <summary>
47-
/// Name of specified form.
53+
/// Name of the form.
4854
/// </summary>
4955
public string Name { get; }
5056

@@ -53,12 +59,18 @@ protected Form(By locator, string name)
5359
/// </summary>
5460
/// <value>True - form is opened,
5561
/// False - form is not opened.</value>
56-
public bool IsDisplayed => FormLabel.State.WaitForDisplayed();
62+
[Obsolete("This property will be removed in the future release. Use State.WaitForDisplayed() if needed")]
63+
public bool IsDisplayed => FormElement.State.WaitForDisplayed();
64+
65+
/// <summary>
66+
/// Provides ability to get form's state (whether it is displayed, exists or not) and respective waiting functions.
67+
/// </summary>
68+
public IElementStateProvider State => FormElement.State;
5769

5870
/// <summary>
5971
/// Gets size of form element defined by its locator.
6072
/// </summary>
61-
public Size Size => FormLabel.GetElement().Size;
73+
public Size Size => FormElement.GetElement().Size;
6274

6375
/// <summary>
6476
/// Scroll form without scrolling entire page
@@ -67,7 +79,7 @@ protected Form(By locator, string name)
6779
/// <param name="y">vertical coordinate</param>
6880
public void ScrollBy(int x, int y)
6981
{
70-
FormLabel.JsActions.ScrollBy(x, y);
82+
FormElement.JsActions.ScrollBy(x, y);
7183
}
7284

7385
/// <summary>
@@ -79,9 +91,11 @@ public void ScrollBy(int x, int y)
7991
/// <param name="supplier">Delegate that defines constructor of child element in case of custom element.</param>
8092
/// <param name="state">Child element state.</param>
8193
/// <returns>Instance of child element.</returns>
82-
protected T FindChildElement<T>(By childLocator, string name = null, ElementSupplier<T> supplier = null, ElementState state = ElementState.Displayed) where T : Core.Elements.Interfaces.IElement
94+
[Obsolete("This method will be removed in the future release. Use FormElement property methods to find child element")]
95+
protected T FindChildElement<T>(By childLocator, string name = null, ElementSupplier<T> supplier = null, ElementState state = ElementState.Displayed)
96+
where T : IElement
8397
{
84-
return FormLabel.FindChildElement(childLocator, name, supplier, state);
98+
return FormElement.FindChildElement(childLocator, name, supplier, state);
8599
}
86100

87101
/// <summary>
@@ -94,9 +108,11 @@ protected T FindChildElement<T>(By childLocator, string name = null, ElementSupp
94108
/// <param name="expectedCount">Expected number of elements that have to be found (zero, more then zero, any).</param>
95109
/// <param name="state">Child elements state.</param>
96110
/// <returns>List of child elements.</returns>
97-
protected IList<T> FindChildElements<T>(By childLocator, string name = null, ElementSupplier<T> supplier = null, ElementsCount expectedCount = ElementsCount.Any, ElementState state = ElementState.Displayed) where T : Core.Elements.Interfaces.IElement
111+
[Obsolete("This method will be removed in the future release. Use FormElement property methods to find child elements")]
112+
protected IList<T> FindChildElements<T>(By childLocator, string name = null, ElementSupplier<T> supplier = null, ElementsCount expectedCount = ElementsCount.Any, ElementState state = ElementState.Displayed)
113+
where T : IElement
98114
{
99-
return FormLabel.FindChildElements(childLocator, name, supplier, expectedCount, state);
115+
return FormElement.FindChildElements(childLocator, name, supplier, expectedCount, state);
100116
}
101117
}
102118
}

Aquality.Selenium/tests/Aquality.Selenium.Tests/Integration/TestApp/AutomationPractice/Forms/ProductTabContentForm.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public IList<Label> GetListElementsByCss(ElementState state, ElementsCount count
4545

4646
public Label GetChildElementByNonXPath(ElementState state)
4747
{
48-
return FindChildElement<Label>(BestSellersById, state: state);
48+
return FormElement.FindChildElement<Label>(BestSellersById, state: state);
4949
}
5050

5151
public IList<Label> GetListElementsByDottedXPath(ElementState state, ElementsCount count)
@@ -55,7 +55,7 @@ public IList<Label> GetListElementsByDottedXPath(ElementState state, ElementsCou
5555

5656
public IList<Label> GetChildElementsByDottedXPath(ElementState state, ElementsCount count)
5757
{
58-
return FindChildElements<Label>(DottedXPath, state: state, expectedCount: count);
58+
return FormElement.FindChildElements<Label>(DottedXPath, state: state, expectedCount: count);
5959
}
6060
}
6161
}

azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ stages:
2828
2929
- task: DotNetCoreCLI@2
3030
displayName: 'Build solution'
31+
env:
32+
MSBUILDSINGLELOADCONTEXT: 1 # https://github.com/SpecFlowOSS/SpecFlow/issues/1912
3133
inputs:
3234
command: 'build'
3335
projects: Aquality.Selenium/Aquality.Selenium.sln

0 commit comments

Comments
 (0)