16
16
public class LocatorTests extends BaseTest {
17
17
private final ChallengingDomForm challengingDomForm = new ChallengingDomForm ();
18
18
private final String labelLocatorCell = "//td" ;
19
- private final String nameElementRow3Column5 = "expectedRow3Column5" ;
20
- private final String nameElementRow7Column5 = "expectedRow7Column5" ;
21
- private final String nameElementRow5Column3 = "expectedRow5Column3" ;
22
- private final String nameElementRow5Column7 = "expectedRow5Column7" ;
23
- private final String nameElementRow5Column5 = "expectedRow5Column5" ;
24
- private final String nameElementRow2Column1 = "expectedRow2Column1" ;
25
- private final String nameElementHeaderOfPage = "Challenging Dom" ;
26
19
private final String friendlyMessageEquallingText = "Actual cell text is not equal expected" ;
27
20
private final String friendlyMessageElementFound = "Element with not reachable distance is exist" ;
28
- private final int positiveDistance = 300 ;
29
- private final int negativeDistance = 100 ;
21
+ private final int distanceToFindElementWithPositiveResult = 300 ;
22
+ private final int distanceToFindElementWithNegativeResult = 100 ;
30
23
31
24
@ BeforeMethod
32
25
public void beforeMethod () {
@@ -39,15 +32,15 @@ public void testAboveLocatorWithDifferentAboveParametersType() {
39
32
40
33
ILabel actualCellRaw3Column5GotWithByXpath =
41
34
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).above (By .xpath (challengingDomForm .getLocatorCellRow5Column5 ())),
42
- nameElementRow3Column5 );
35
+ ChallengingDomForm . ELEMENT_NAME_ROW3_COLUMN5 );
43
36
44
37
ILabel actualCellRaw3Column5GotWithWebElement =
45
38
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).above (cellInRow5Column5 .getElement ()),
46
- nameElementRow3Column5 );
39
+ ChallengingDomForm . ELEMENT_NAME_ROW3_COLUMN5 );
47
40
48
41
ILabel actualCellRaw3Column5GotWithAqualityElement =
49
42
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).above (cellInRow5Column5 ),
50
- nameElementRow3Column5 );
43
+ ChallengingDomForm . ELEMENT_NAME_ROW3_COLUMN5 );
51
44
52
45
WebElement actualWebElementCellRaw3Column5GotBySeleniumRelative =
53
46
getBrowser ().getDriver ().findElement (RelativeLocator
@@ -68,15 +61,15 @@ public void testBelowLocatorWithDifferentBelowParametersType() {
68
61
69
62
ILabel actualCellRaw7Column5GotWithByXpath =
70
63
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).below (By .xpath (challengingDomForm .getLocatorCellRow5Column5 ())),
71
- nameElementRow7Column5 );
64
+ ChallengingDomForm . ELEMENT_NAME_ROW7_COLUMN5 );
72
65
73
66
ILabel actualCellRaw7Column5GotWithWebElement =
74
67
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).below (cellInRow5Column5 .getElement ()),
75
- nameElementRow7Column5 );
68
+ ChallengingDomForm . ELEMENT_NAME_ROW7_COLUMN5 );
76
69
77
70
ILabel actualCellRaw7Column5GotWithAqualityElement =
78
71
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).below (cellInRow5Column5 ),
79
- nameElementRow7Column5 );
72
+ ChallengingDomForm . ELEMENT_NAME_ROW7_COLUMN5 );
80
73
81
74
WebElement actualWebElementCellRaw7Column5GotBySeleniumRelative =
82
75
getBrowser ().getDriver ().findElement (RelativeLocator
@@ -91,22 +84,21 @@ public void testBelowLocatorWithDifferentBelowParametersType() {
91
84
challengingDomForm .getCellInRow7Column5 ().getText ());
92
85
}
93
86
94
-
95
87
@ Test
96
88
public void testToLeftOfLocatorWithDifferentToLeftOfParametersType () {
97
89
ILabel cellInRow5Column5 = challengingDomForm .getCellInRow5Column5 ();
98
90
99
91
ILabel actualCellRaw5Column3GotWithByXpath =
100
92
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toLeftOf (By .xpath (challengingDomForm .getLocatorCellRow5Column5 ())),
101
- nameElementRow5Column3 );
93
+ ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN3 );
102
94
103
95
ILabel actualCellRaw5Column3GotWithWebElement =
104
96
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toLeftOf (cellInRow5Column5 .getElement ()),
105
- nameElementRow5Column3 );
97
+ ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN3 );
106
98
107
99
ILabel actualCellRaw5Column3GotWithAqualityElement =
108
100
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toLeftOf (cellInRow5Column5 ),
109
- nameElementRow5Column3 );
101
+ ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN3 );
110
102
111
103
WebElement actualWebElementCellRaw5Column3GotBySeleniumRelative =
112
104
getBrowser ().getDriver ().findElement (RelativeLocator
@@ -127,15 +119,15 @@ public void testToRightOfLocatorWithDifferentToRightOfParametersType() {
127
119
128
120
ILabel actualCellRaw5Column7GotWithByXpath =
129
121
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toRightOf (By .xpath (challengingDomForm .getLocatorCellRow5Column5 ())),
130
- nameElementRow5Column7 );
122
+ ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN7 );
131
123
132
124
ILabel actualCellRaw5Column7GotWithWebElement =
133
125
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toRightOf (cellInRow5Column5 .getElement ()),
134
- nameElementRow5Column3 );
126
+ ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN7 );
135
127
136
128
ILabel actualCellRaw5Column7GotWithAqualityElement =
137
129
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).toRightOf (cellInRow5Column5 ),
138
- nameElementRow5Column3 );
130
+ ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN7 );
139
131
140
132
WebElement actualWebElementCellRaw5Column7GotBySeleniumRelative =
141
133
getBrowser ().getDriver ().findElement (RelativeLocator
@@ -160,12 +152,12 @@ public void testAboveBelowLeftRight() {
160
152
161
153
ILabel actualCellRaw5Column5GotWithAqualityElement =
162
154
elementFactory .getLabel (with (By .xpath (labelLocatorCell ))
163
- .above (cellInRow7Column5 )
164
- .below (cellInRow3Column5 )
165
- .toRightOf (cellInRow5Column3 )
166
- .toLeftOf (cellInRow5Column7 )
167
- .above (cellInRow7Column5 )
168
- , nameElementRow5Column5 );
155
+ .above (cellInRow7Column5 )
156
+ .below (cellInRow3Column5 )
157
+ .toRightOf (cellInRow5Column3 )
158
+ .toLeftOf (cellInRow5Column7 )
159
+ .above (cellInRow7Column5 )
160
+ , ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN5 );
169
161
170
162
ILabel actualCellRaw5Column5GotWithWebElement =
171
163
elementFactory .getLabel (with (By .xpath (labelLocatorCell ))
@@ -174,7 +166,7 @@ public void testAboveBelowLeftRight() {
174
166
.toRightOf (cellInRow5Column3 .getElement ())
175
167
.toLeftOf (cellInRow5Column7 .getElement ())
176
168
.above (cellInRow7Column5 .getElement ())
177
- , nameElementRow5Column5 );
169
+ , ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN5 );
178
170
179
171
ILabel actualCellRaw5Column5GotWithXpath =
180
172
elementFactory .getLabel (with (By .xpath (labelLocatorCell ))
@@ -183,7 +175,7 @@ public void testAboveBelowLeftRight() {
183
175
.toRightOf (By .xpath (challengingDomForm .getLocatorCellRow5Column3 ()))
184
176
.toLeftOf (By .xpath (challengingDomForm .getLocatorCellRow5Column7 ()))
185
177
.above (By .xpath (challengingDomForm .getLocatorCellRow7Column5 ()))
186
- , nameElementRow5Column5 );
178
+ , ChallengingDomForm . ELEMENT_NAME_ROW5_COLUMN5 );
187
179
188
180
WebElement actualWebElementCellRaw5Column5GotBySeleniumRelative =
189
181
getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (labelLocatorCell ))
@@ -205,15 +197,15 @@ public void testAboveBelowLeftRight() {
205
197
public void testNear () {
206
198
ILabel actualCellRaw2Column1GotWithAqualityElement =
207
199
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).near (challengingDomForm .getCellInRow1Column1 ()),
208
- nameElementRow2Column1 );
200
+ ChallengingDomForm . ELEMENT_NAME_ROW2_COLUMN1 );
209
201
210
202
ILabel actualCellRaw2Column1GotWithWebElement =
211
203
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).near (challengingDomForm .getCellInRow1Column1 ().getElement ()),
212
- nameElementRow2Column1 );
204
+ ChallengingDomForm . ELEMENT_NAME_ROW2_COLUMN1 );
213
205
214
206
ILabel actualCellRaw2Column1GotWithXpath =
215
207
elementFactory .getLabel (with (By .xpath (labelLocatorCell )).near (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ())),
216
- nameElementRow2Column1 );
208
+ ChallengingDomForm . ELEMENT_NAME_ROW2_COLUMN1 );
217
209
218
210
219
211
WebElement actualWebElementCellRaw2Column1GotBySeleniumRelative =
@@ -232,23 +224,23 @@ public void testNear() {
232
224
public void testNearWithDistance () {
233
225
ILabel actualHeaderNameGotWithAqualityElement =
234
226
elementFactory .getLabel (with (By .xpath (ChallengingDomForm .LOCATOR_CHALLENGING_DOM_FORM ))
235
- .near (challengingDomForm .getCellInRow1Column1 (), positiveDistance ),
236
- nameElementHeaderOfPage );
227
+ .near (challengingDomForm .getCellInRow1Column1 (), distanceToFindElementWithPositiveResult ),
228
+ ChallengingDomForm . ELEMENT_NAME_HEADER_CHALLENGING_DOM );
237
229
238
230
ILabel actualHeaderNameGotWithWebElement =
239
231
elementFactory .getLabel (with (By .xpath (ChallengingDomForm .LOCATOR_CHALLENGING_DOM_FORM ))
240
- .near (challengingDomForm .getCellInRow1Column1 ().getElement (), positiveDistance ),
241
- nameElementHeaderOfPage );
232
+ .near (challengingDomForm .getCellInRow1Column1 ().getElement (), distanceToFindElementWithPositiveResult ),
233
+ ChallengingDomForm . ELEMENT_NAME_HEADER_CHALLENGING_DOM );
242
234
243
235
ILabel actualHeaderNameGotWithXpath =
244
236
elementFactory .getLabel (with (By .xpath (ChallengingDomForm .LOCATOR_CHALLENGING_DOM_FORM ))
245
- .near (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ()), positiveDistance ),
246
- nameElementHeaderOfPage );
237
+ .near (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ()), distanceToFindElementWithPositiveResult ),
238
+ ChallengingDomForm . ELEMENT_NAME_HEADER_CHALLENGING_DOM );
247
239
248
240
249
241
WebElement actualWebElementHeaderNameGotBySeleniumRelative =
250
242
getBrowser ().getDriver ().findElement (RelativeLocator .with (By .xpath (ChallengingDomForm .LOCATOR_CHALLENGING_DOM_FORM ))
251
- .near (getBrowser ().getDriver ().findElement (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ())),positiveDistance ));
243
+ .near (getBrowser ().getDriver ().findElement (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ())), distanceToFindElementWithPositiveResult ));
252
244
253
245
checkDifferentTypesWithSoftAssert (
254
246
actualHeaderNameGotWithAqualityElement .getText (),
@@ -262,29 +254,29 @@ public void testNearWithDistance() {
262
254
public void testNearWithDistanceNegative () {
263
255
ILabel actualHeaderNameGotWithAqualityElement =
264
256
elementFactory .getLabel (with (By .xpath (ChallengingDomForm .LOCATOR_CHALLENGING_DOM_FORM ))
265
- .near (challengingDomForm .getCellInRow1Column1 (), negativeDistance ),
266
- nameElementHeaderOfPage );
257
+ .near (challengingDomForm .getCellInRow1Column1 (), distanceToFindElementWithNegativeResult ),
258
+ ChallengingDomForm . ELEMENT_NAME_HEADER_CHALLENGING_DOM );
267
259
268
260
ILabel actualHeaderNameGotWithWebElement =
269
261
elementFactory .getLabel (with (By .xpath (ChallengingDomForm .LOCATOR_CHALLENGING_DOM_FORM ))
270
- .near (challengingDomForm .getCellInRow1Column1 ().getElement (), negativeDistance ),
271
- nameElementHeaderOfPage );
262
+ .near (challengingDomForm .getCellInRow1Column1 ().getElement (), distanceToFindElementWithNegativeResult ),
263
+ ChallengingDomForm . ELEMENT_NAME_HEADER_CHALLENGING_DOM );
272
264
273
265
ILabel actualHeaderNameGotWithXpath =
274
266
elementFactory .getLabel (with (By .xpath (ChallengingDomForm .LOCATOR_CHALLENGING_DOM_FORM ))
275
- .near (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ()), negativeDistance ),
276
- nameElementHeaderOfPage );
267
+ .near (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ()), distanceToFindElementWithNegativeResult ),
268
+ ChallengingDomForm . ELEMENT_NAME_HEADER_CHALLENGING_DOM );
277
269
278
270
279
271
List <WebElement > actualsWebElementsHeaderNameGotBySeleniumRelative =
280
272
getBrowser ().getDriver ().findElements (RelativeLocator .with (By .xpath (ChallengingDomForm .LOCATOR_CHALLENGING_DOM_FORM ))
281
- .near (getBrowser ().getDriver ().findElement (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ())), negativeDistance ));
273
+ .near (getBrowser ().getDriver ().findElement (By .xpath (challengingDomForm .getLocatorCellRow1Column1 ())), distanceToFindElementWithNegativeResult ));
282
274
283
275
SoftAssert softAssert = new SoftAssert ();
284
276
softAssert .assertFalse (actualHeaderNameGotWithAqualityElement .state ().isExist (), friendlyMessageElementFound );
285
277
softAssert .assertFalse (actualHeaderNameGotWithWebElement .state ().isExist (), friendlyMessageElementFound );
286
278
softAssert .assertFalse (actualHeaderNameGotWithXpath .state ().isExist (), friendlyMessageElementFound );
287
- softAssert .assertEquals (actualsWebElementsHeaderNameGotBySeleniumRelative .size (),0 , "Elements with not reachable distance was found" );
279
+ softAssert .assertEquals (actualsWebElementsHeaderNameGotBySeleniumRelative .size (), 0 , friendlyMessageElementFound );
288
280
softAssert .assertAll ();
289
281
}
290
282
0 commit comments