11package tests .integration ;
22
33import aquality .selenium .elements .interfaces .ILabel ;
4+ import automationpractice .forms .ChallengingDomForm ;
45import org .openqa .selenium .By ;
56import org .openqa .selenium .WebElement ;
67import org .openqa .selenium .support .locators .RelativeLocator ;
1314import static aquality .selenium .locators .RelativeBySupplier .with ;
1415
1516public class LocatorTests extends BaseTest {
17+ private final ChallengingDomForm challengingDomForm = new ChallengingDomForm ();
1618 private final String labelLocatorCell = "//td" ;
17- private final String labelLocatorCellRow5Column5 = "//tr[5]/td[5]" ;
18- private final String labelLocatorCellRow3Column5 = "//tr[3]/td[5]" ;
19- private final String labelLocatorCellRow7Column5 = "//tr[7]/td[5]" ;
20- private final String labelLocatorCellRow5Column3 = "//tr[5]/td[3]" ;
21- private final String labelLocatorCellRow5Column7 = "//tr[5]/td[7]" ;
2219 private final String nameElementRow3Column5 = "expectedRow3Column5GotWithByXpath" ;
2320 private final String nameElementRow7Column5 = "expectedRow7Column5GotWithByXpath" ;
2421 private final String nameElementRow5Column3 = "expectedRow5Column3GotWithByXpath" ;
@@ -33,12 +30,11 @@ public void beforeMethod() {
3330
3431 @ Test
3532 public void testAboveLocatorWithDifferentAboveParametersType () {
36-
37- ILabel cellInRow3Column5 = elementFactory .getLabel (By .xpath (labelLocatorCellRow3Column5 ), "CellInRow3Column5" );
38- ILabel cellInRow5Column5 = elementFactory .getLabel (By .xpath (labelLocatorCellRow5Column5 ), "CellInRow5Column5" );
33+ ILabel cellInRow3Column5 = challengingDomForm .getCellInRow3Column5 ();
34+ ILabel cellInRow5Column5 = challengingDomForm .getCellInRow5Column5 ();
3935
4036 ILabel actualCellRaw3Column5GotWithByXpath =
41- elementFactory .getLabel (with (By .xpath (labelLocatorCell )).above (By .xpath (labelLocatorCellRow5Column5 )),
37+ elementFactory .getLabel (with (By .xpath (labelLocatorCell )).above (By .xpath (challengingDomForm . getLocatorCellRow5Column5 () )),
4238 nameElementRow3Column5 );
4339
4440 ILabel actualCellRaw3Column5GotWithWebElement =
@@ -50,7 +46,7 @@ public void testAboveLocatorWithDifferentAboveParametersType() {
5046 nameElementRow3Column5 );
5147
5248 WebElement actualWebElementCellRaw3Column5GotBySeleniumRelative =
53- getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell )).above (By .xpath (labelLocatorCellRow5Column5 )));
49+ getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell )).above (By .xpath (challengingDomForm . getLocatorCellRow5Column5 () )));
5450
5551 checkDifferentTypesWithSoftAssert (
5652 actualCellRaw3Column5GotWithAqualityElement .getText (),
@@ -63,11 +59,11 @@ public void testAboveLocatorWithDifferentAboveParametersType() {
6359 @ Test
6460 public void testBelowLocatorWithDifferentBelowParametersType () {
6561
66- ILabel cellInRow7Column5 = elementFactory . getLabel ( By . xpath ( labelLocatorCellRow7Column5 ), "CellInRow7Column5" );
67- ILabel cellInRow5Column5 = elementFactory . getLabel ( By . xpath ( labelLocatorCellRow5Column5 ), "CellInRow5Column5" );
62+ ILabel cellInRow7Column5 = challengingDomForm . getCellInRow7Column5 ( );
63+ ILabel cellInRow5Column5 = challengingDomForm . getCellInRow5Column5 ( );
6864
6965 ILabel actualCellRaw7Column5GotWithByXpath =
70- elementFactory .getLabel (with (By .xpath (labelLocatorCell )).below (By .xpath (labelLocatorCellRow5Column5 )),
66+ elementFactory .getLabel (with (By .xpath (labelLocatorCell )).below (By .xpath (challengingDomForm . getLocatorCellRow5Column5 () )),
7167 nameElementRow7Column5 );
7268
7369 ILabel actualCellRaw7Column5GotWithWebElement =
@@ -79,7 +75,7 @@ public void testBelowLocatorWithDifferentBelowParametersType () {
7975 nameElementRow7Column5 );
8076
8177 WebElement actualWebElementCellRaw7Column5GotBySeleniumRelative =
82- getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell )).below (By .xpath (labelLocatorCellRow5Column5 )));
78+ getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell )).below (By .xpath (challengingDomForm . getLocatorCellRow5Column5 () )));
8379
8480 checkDifferentTypesWithSoftAssert (
8581 actualCellRaw7Column5GotWithAqualityElement .getText (),
@@ -93,11 +89,11 @@ public void testBelowLocatorWithDifferentBelowParametersType () {
9389 @ Test
9490 public void testToLeftOfLocatorWithDifferentToLeftOfParametersType () {
9591
96- ILabel cellInRow5Column3 = elementFactory . getLabel ( By . xpath ( labelLocatorCellRow5Column3 ), "CellInRow5Column3" );
97- ILabel cellInRow5Column5 = elementFactory . getLabel ( By . xpath ( labelLocatorCellRow5Column5 ), "CellInRow5Column5" );
92+ ILabel cellInRow5Column3 = challengingDomForm . getCellInRow5Column3 ( );
93+ ILabel cellInRow5Column5 = challengingDomForm . getCellInRow5Column5 ( );
9894
9995 ILabel actualCellRaw5Column3GotWithByXpath =
100- elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toLeftOf (By .xpath (labelLocatorCellRow5Column5 )),
96+ elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toLeftOf (By .xpath (challengingDomForm . getLocatorCellRow5Column5 () )),
10197 nameElementRow5Column3 );
10298
10399 ILabel actualCellRaw5Column3GotWithWebElement =
@@ -109,7 +105,7 @@ public void testToLeftOfLocatorWithDifferentToLeftOfParametersType () {
109105 nameElementRow5Column3 );
110106
111107 WebElement actualWebElementCellRaw5Column3GotBySeleniumRelative =
112- getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell )).toLeftOf (By .xpath (labelLocatorCellRow5Column5 )));
108+ getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell )).toLeftOf (By .xpath (challengingDomForm . getLocatorCellRow5Column5 () )));
113109
114110 checkDifferentTypesWithSoftAssert (
115111 actualCellRaw5Column3GotWithAqualityElement .getText (),
@@ -121,12 +117,11 @@ public void testToLeftOfLocatorWithDifferentToLeftOfParametersType () {
121117
122118 @ Test
123119 public void testToRightOfLocatorWithDifferentToRightOfParametersType () {
124-
125- ILabel cellInRow5Column7 = elementFactory .getLabel (By .xpath (labelLocatorCellRow5Column7 ), "CellInRow5Column7" );
126- ILabel cellInRow5Column5 = elementFactory .getLabel (By .xpath (labelLocatorCellRow5Column5 ), "CellInRow5Column5" );
120+ ILabel cellInRow5Column7 = challengingDomForm .getCellInRow5Column7 ();
121+ ILabel cellInRow5Column5 = challengingDomForm .getCellInRow5Column5 ();
127122
128123 ILabel actualCellRaw5Column7GotWithByXpath =
129- elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toRightOf (By .xpath (labelLocatorCellRow5Column5 )),
124+ elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toRightOf (By .xpath (challengingDomForm . getLocatorCellRow5Column5 () )),
130125 nameElementRow5Column7 );
131126
132127 ILabel actualCellRaw5Column7GotWithWebElement =
@@ -138,7 +133,7 @@ public void testToRightOfLocatorWithDifferentToRightOfParametersType () {
138133 nameElementRow5Column3 );
139134
140135 WebElement actualWebElementCellRaw5Column7GotBySeleniumRelative =
141- getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell )).toRightOf (By .xpath (labelLocatorCellRow5Column5 )));
136+ getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell )).toRightOf (By .xpath (challengingDomForm . getLocatorCellRow5Column5 () )));
142137
143138 checkDifferentTypesWithSoftAssert (
144139 actualCellRaw5Column7GotWithAqualityElement .getText (),
@@ -150,12 +145,11 @@ public void testToRightOfLocatorWithDifferentToRightOfParametersType () {
150145
151146 @ Test
152147 public void testAboveBelowLeftRight () {
153-
154- ILabel cellInRow3Column5 = elementFactory .getLabel (By .xpath (labelLocatorCellRow3Column5 ), "CellInRow3Column5" );
155- ILabel cellInRow5Column7 = elementFactory .getLabel (By .xpath (labelLocatorCellRow5Column7 ), "CellInRow5Column7" );
156- ILabel cellInRow5Column5 = elementFactory .getLabel (By .xpath (labelLocatorCellRow5Column5 ), "CellInRow5Column5" );
157- ILabel cellInRow5Column3 = elementFactory .getLabel (By .xpath (labelLocatorCellRow5Column3 ), "CellInRow5Column3" );
158- ILabel cellInRow7Column5 = elementFactory .getLabel (By .xpath (labelLocatorCellRow7Column5 ), "CellInRow7Column5" );
148+ ILabel cellInRow3Column5 = challengingDomForm .getCellInRow3Column5 ();
149+ ILabel cellInRow5Column7 = challengingDomForm .getCellInRow5Column7 ();
150+ ILabel cellInRow5Column5 = challengingDomForm .getCellInRow5Column5 ();
151+ ILabel cellInRow5Column3 = challengingDomForm .getCellInRow5Column3 ();
152+ ILabel cellInRow7Column5 = challengingDomForm .getCellInRow7Column5 ();
159153
160154 ILabel actualCellRaw5Column5GotWithAqualityElement =
161155 elementFactory .getLabel (with (By .xpath (labelLocatorCell ))
@@ -176,20 +170,20 @@ public void testAboveBelowLeftRight() {
176170
177171 ILabel actualCellRaw5Column5GotWithXpath =
178172 elementFactory .getLabel (with (By .xpath (labelLocatorCell ))
179- .above (By .xpath (labelLocatorCellRow7Column5 ))
180- .below (By .xpath (labelLocatorCellRow3Column5 ))
181- .toRightOf (By .xpath (labelLocatorCellRow5Column3 ))
182- .toLeftOf (By .xpath (labelLocatorCellRow5Column7 ))
183- .above (By .xpath (labelLocatorCellRow7Column5 ))
173+ .above (By .xpath (challengingDomForm . getLocatorCellRow7Column5 () ))
174+ .below (By .xpath (challengingDomForm . getLocatorCellRow3Column5 () ))
175+ .toRightOf (By .xpath (challengingDomForm . getLocatorCellRow5Column3 () ))
176+ .toLeftOf (By .xpath (challengingDomForm . getLocatorCellRow5Column7 () ))
177+ .above (By .xpath (challengingDomForm . getLocatorCellRow7Column5 () ))
184178 , nameElementRow5Column5 );
185179
186180 WebElement actualWebElementCellRaw5Column5GotBySeleniumRelative =
187181 getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell ))
188- .above (By .xpath (labelLocatorCellRow7Column5 ))
189- .below (By .xpath (labelLocatorCellRow3Column5 ))
190- .toRightOf (By .xpath (labelLocatorCellRow5Column3 ))
191- .toLeftOf (By .xpath (labelLocatorCellRow5Column7 ))
192- .above (By .xpath (labelLocatorCellRow7Column5 ))
182+ .above (By .xpath (challengingDomForm . getLocatorCellRow7Column5 () ))
183+ .below (By .xpath (challengingDomForm . getLocatorCellRow3Column5 () ))
184+ .toRightOf (By .xpath (challengingDomForm . getLocatorCellRow5Column3 () ))
185+ .toLeftOf (By .xpath (challengingDomForm . getLocatorCellRow5Column7 () ))
186+ .above (By .xpath (challengingDomForm . getLocatorCellRow7Column5 () ))
193187 );
194188
195189 checkDifferentTypesWithSoftAssert (
0 commit comments