1- using Aquality . Selenium . Elements . Interfaces ;
2- using OpenQA . Selenium ;
1+ using System ;
2+ using System . Collections . Generic ;
33using System . Drawing ;
4- using Aquality . Selenium . Browsers ;
5- using Aquality . Selenium . Core . Localization ;
4+ using OpenQA . Selenium ;
65using 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
911namespace 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}
0 commit comments