11package aquality .selenium .forms ;
22
33import aquality .selenium .browser .AqualityServices ;
4+ import aquality .selenium .core .configurations .IVisualizationConfiguration ;
45import aquality .selenium .core .elements .interfaces .IElementStateProvider ;
56import aquality .selenium .core .localization .ILocalizedLogger ;
7+ import aquality .selenium .elements .interfaces .IElement ;
68import aquality .selenium .elements .interfaces .IElementFactory ;
79import aquality .selenium .elements .interfaces .ILabel ;
810import org .openqa .selenium .By ;
9- import org .openqa .selenium .Dimension ;
11+
12+ import java .awt .*;
1013
1114/**
1215 * Defines base class for any UI form.
1316 */
14- public abstract class Form {
17+ public abstract class Form extends aquality .selenium .core .forms .Form <IElement > {
18+ /**
19+ * Label of form element defined by its locator and name.
20+ */
21+ private final ILabel formLabel ;
1522 /**
1623 * Locator for specified form
1724 */
@@ -25,8 +32,10 @@ public abstract class Form {
2532 * Constructor with parameters
2633 */
2734 protected Form (By locator , String name ) {
35+ super (IElement .class );
2836 this .locator = locator ;
2937 this .name = name ;
38+ formLabel = getElementFactory ().getLabel (locator , name );
3039 }
3140
3241 /**
@@ -83,7 +92,7 @@ public void scrollBy(int x, int y) {
8392 * @return Size of the form element.
8493 */
8594 public Dimension getSize () {
86- return getFormLabel ().getElement ().getSize ();
95+ return getFormLabel ().visual ().getSize ();
8796 }
8897
8998
@@ -94,7 +103,7 @@ public Dimension getSize() {
94103 * @return Label of form element.
95104 */
96105 protected ILabel getFormLabel () {
97- return getElementFactory (). getLabel ( locator , name ) ;
106+ return formLabel ;
98107 }
99108
100109 /**
@@ -111,7 +120,18 @@ protected IElementFactory getElementFactory() {
111120 *
112121 * @return instance of localized logger.
113122 */
114- protected ILocalizedLogger getLogger () {
123+ @ Override
124+ protected ILocalizedLogger getLocalizedLogger () {
115125 return AqualityServices .getLocalizedLogger ();
116126 }
127+
128+ /**
129+ * Visualization configuration used by dump().
130+ *
131+ * @return instance of visualization configuration.
132+ */
133+ @ Override
134+ protected IVisualizationConfiguration getVisualizationConfiguration () {
135+ return AqualityServices .getConfiguration ().getVisualizationConfiguration ();
136+ }
117137}
0 commit comments