1
1
package tests .integration ;
2
2
3
3
import aquality .selenium .elements .interfaces .ILabel ;
4
+ import automationpractice .forms .ChallengingDomForm ;
4
5
import org .openqa .selenium .By ;
5
6
import org .openqa .selenium .WebElement ;
6
7
import org .openqa .selenium .support .locators .RelativeLocator ;
13
14
import static aquality .selenium .locators .RelativeBySupplier .with ;
14
15
15
16
public class LocatorTests extends BaseTest {
17
+ private final ChallengingDomForm challengingDomForm = new ChallengingDomForm ();
16
18
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]" ;
22
19
private final String nameElementRow3Column5 = "expectedRow3Column5GotWithByXpath" ;
23
20
private final String nameElementRow7Column5 = "expectedRow7Column5GotWithByXpath" ;
24
21
private final String nameElementRow5Column3 = "expectedRow5Column3GotWithByXpath" ;
@@ -33,12 +30,11 @@ public void beforeMethod() {
33
30
34
31
@ Test
35
32
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 ();
39
35
40
36
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 () )),
42
38
nameElementRow3Column5 );
43
39
44
40
ILabel actualCellRaw3Column5GotWithWebElement =
@@ -50,7 +46,7 @@ public void testAboveLocatorWithDifferentAboveParametersType() {
50
46
nameElementRow3Column5 );
51
47
52
48
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 () )));
54
50
55
51
checkDifferentTypesWithSoftAssert (
56
52
actualCellRaw3Column5GotWithAqualityElement .getText (),
@@ -63,11 +59,11 @@ public void testAboveLocatorWithDifferentAboveParametersType() {
63
59
@ Test
64
60
public void testBelowLocatorWithDifferentBelowParametersType () {
65
61
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 ( );
68
64
69
65
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 () )),
71
67
nameElementRow7Column5 );
72
68
73
69
ILabel actualCellRaw7Column5GotWithWebElement =
@@ -79,7 +75,7 @@ public void testBelowLocatorWithDifferentBelowParametersType () {
79
75
nameElementRow7Column5 );
80
76
81
77
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 () )));
83
79
84
80
checkDifferentTypesWithSoftAssert (
85
81
actualCellRaw7Column5GotWithAqualityElement .getText (),
@@ -93,11 +89,11 @@ public void testBelowLocatorWithDifferentBelowParametersType () {
93
89
@ Test
94
90
public void testToLeftOfLocatorWithDifferentToLeftOfParametersType () {
95
91
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 ( );
98
94
99
95
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 () )),
101
97
nameElementRow5Column3 );
102
98
103
99
ILabel actualCellRaw5Column3GotWithWebElement =
@@ -109,7 +105,7 @@ public void testToLeftOfLocatorWithDifferentToLeftOfParametersType () {
109
105
nameElementRow5Column3 );
110
106
111
107
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 () )));
113
109
114
110
checkDifferentTypesWithSoftAssert (
115
111
actualCellRaw5Column3GotWithAqualityElement .getText (),
@@ -121,12 +117,11 @@ public void testToLeftOfLocatorWithDifferentToLeftOfParametersType () {
121
117
122
118
@ Test
123
119
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 ();
127
122
128
123
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 () )),
130
125
nameElementRow5Column7 );
131
126
132
127
ILabel actualCellRaw5Column7GotWithWebElement =
@@ -138,7 +133,7 @@ public void testToRightOfLocatorWithDifferentToRightOfParametersType () {
138
133
nameElementRow5Column3 );
139
134
140
135
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 () )));
142
137
143
138
checkDifferentTypesWithSoftAssert (
144
139
actualCellRaw5Column7GotWithAqualityElement .getText (),
@@ -150,12 +145,11 @@ public void testToRightOfLocatorWithDifferentToRightOfParametersType () {
150
145
151
146
@ Test
152
147
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 ();
159
153
160
154
ILabel actualCellRaw5Column5GotWithAqualityElement =
161
155
elementFactory .getLabel (with (By .xpath (labelLocatorCell ))
@@ -176,20 +170,20 @@ public void testAboveBelowLeftRight() {
176
170
177
171
ILabel actualCellRaw5Column5GotWithXpath =
178
172
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 () ))
184
178
, nameElementRow5Column5 );
185
179
186
180
WebElement actualWebElementCellRaw5Column5GotBySeleniumRelative =
187
181
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 () ))
193
187
);
194
188
195
189
checkDifferentTypesWithSoftAssert (
0 commit comments