1
- using Aquality . Selenium . Elements . Interfaces ;
2
- using OpenQA . Selenium ;
1
+ using System ;
2
+ using System . Collections . Generic ;
3
3
using System . Drawing ;
4
- using Aquality . Selenium . Browsers ;
5
- using Aquality . Selenium . Core . Localization ;
4
+ using OpenQA . Selenium ;
6
5
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 ;
8
10
9
11
namespace Aquality . Selenium . Forms
10
12
{
@@ -13,6 +15,7 @@ namespace Aquality.Selenium.Forms
13
15
/// </summary>
14
16
public abstract class Form
15
17
{
18
+ private readonly ILabel formLabel ;
16
19
/// <summary>
17
20
/// Constructor with parameters.
18
21
/// </summary>
@@ -22,29 +25,32 @@ protected Form(By locator, string name)
22
25
{
23
26
Locator = locator ;
24
27
Name = name ;
28
+ formLabel = ElementFactory . GetLabel ( Locator , Name ) ;
25
29
}
26
30
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 ;
28
36
29
37
/// <summary>
30
- /// Instance of logger <see cref="Logging.Logger">
38
+ /// Instance of logger <see cref="Core. Logging.Logger"/ >
31
39
/// </summary>
32
- /// <value>Logger instance.</value>
33
- protected ILocalizedLogger Logger => AqualityServices . LocalizedLogger ;
40
+ protected static Logger Logger => AqualityServices . Logger ;
34
41
35
42
/// <summary>
36
- /// Element factory <see cref="IElementFactory">
43
+ /// Element factory <see cref="IElementFactory"/ >
37
44
/// </summary>
38
- /// <value>Element factory.</value>
39
- protected IElementFactory ElementFactory => AqualityServices . Get < IElementFactory > ( ) ;
45
+ protected static IElementFactory ElementFactory => AqualityServices . Get < IElementFactory > ( ) ;
40
46
41
47
/// <summary>
42
- /// Locator of specified form.
48
+ /// Locator of the form.
43
49
/// </summary>
44
50
public By Locator { get ; }
45
51
46
52
/// <summary>
47
- /// Name of specified form.
53
+ /// Name of the form.
48
54
/// </summary>
49
55
public string Name { get ; }
50
56
@@ -53,12 +59,18 @@ protected Form(By locator, string name)
53
59
/// </summary>
54
60
/// <value>True - form is opened,
55
61
/// 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 ;
57
69
58
70
/// <summary>
59
71
/// Gets size of form element defined by its locator.
60
72
/// </summary>
61
- public Size Size => FormLabel . GetElement ( ) . Size ;
73
+ public Size Size => FormElement . GetElement ( ) . Size ;
62
74
63
75
/// <summary>
64
76
/// Scroll form without scrolling entire page
@@ -67,7 +79,7 @@ protected Form(By locator, string name)
67
79
/// <param name="y">vertical coordinate</param>
68
80
public void ScrollBy ( int x , int y )
69
81
{
70
- FormLabel . JsActions . ScrollBy ( x , y ) ;
82
+ FormElement . JsActions . ScrollBy ( x , y ) ;
71
83
}
72
84
73
85
/// <summary>
@@ -79,9 +91,11 @@ public void ScrollBy(int x, int y)
79
91
/// <param name="supplier">Delegate that defines constructor of child element in case of custom element.</param>
80
92
/// <param name="state">Child element state.</param>
81
93
/// <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
83
97
{
84
- return FormLabel . FindChildElement ( childLocator , name , supplier , state ) ;
98
+ return FormElement . FindChildElement ( childLocator , name , supplier , state ) ;
85
99
}
86
100
87
101
/// <summary>
@@ -94,9 +108,11 @@ protected T FindChildElement<T>(By childLocator, string name = null, ElementSupp
94
108
/// <param name="expectedCount">Expected number of elements that have to be found (zero, more then zero, any).</param>
95
109
/// <param name="state">Child elements state.</param>
96
110
/// <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
98
114
{
99
- return FormLabel . FindChildElements ( childLocator , name , supplier , expectedCount , state ) ;
115
+ return FormElement . FindChildElements ( childLocator , name , supplier , expectedCount , state ) ;
100
116
}
101
117
}
102
118
}
0 commit comments