Skip to content

Commit a7197a5

Browse files
committed
[1.4.2-documentation] - added java docs
1 parent f56971a commit a7197a5

File tree

4 files changed

+566
-9
lines changed

4 files changed

+566
-9
lines changed

readme.md

Lines changed: 177 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
EXECUTOR=http://{host}:{port}/wd/hub
8080
DEVICE=Device name or ID
8181

82-
### Possibilities ###
82+
### Responsive UI Validation ###
8383
- Responsive UI Validator allows to validate UI on web or mobile page using lots of criterias. Also it allows tu build thr HTMl report after validation.
8484

8585
ResponsiveUIValidator uiValidator = new ResponsiveUIValidator(driver);
@@ -106,7 +106,183 @@
106106

107107

108108
uiValidator.generateReport();
109+
110+
- Description for each methods available in the framework:
111+
112+
* Init method:
113+
114+
init(); // Method that defines start of new validation. Needs to be called each time before calling findElement(), findElements()
115+
116+
init("Scenario name"); // Method that defines start of new validation with specified name of scenario. Needs to be called each time before calling findElement(), findElements()
117+
118+
setColorForRootElement(Color color); // Set color for main element. This color will be used for highlighting element in results
119+
120+
setColorForHighlightedElements(Color color); // Set color for compared elements. This color will be used for highlighting elements in results
121+
122+
setLinesColor(Color color); // Set color for grid lines. This color will be used for the lines of alignment grid in results
123+
124+
findElement(WebElement element, String readableNameOfElement); // Main method to specify which element we want to validate (can be called only findElement() OR findElements() for single validation)
125+
126+
findElements(List<WebElement> elements); // Main method to specify the list of elements that we want to validate (can be called only findElement() OR findElements() for single validation)
127+
128+
* For single element findElement({element}, "name"):
129+
130+
insideOf(WebElement containerElement, String readableContainerName); // Verify that element is located inside of specified element
131+
132+
withLeftElement(WebElement element); // Verify that element which located left to is correct
133+
134+
135+
withLeftElement(WebElement element, int minMargin, int maxMargin); // Verify that element which located left to is correct with specified margins
136+
137+
138+
withRightElement(WebElement element); // Verify that element which located right to is correct
139+
140+
141+
withRightElement(WebElement element, int minMargin, int maxMargin); // Verify that element which located right to is correct with specified margins
142+
143+
144+
withTopElement(WebElement element); // Verify that element which located top to is correct
145+
146+
147+
withTopElement(WebElement element, int minMargin, int maxMargin); // Verify that element which located top to is correct with specified margins
148+
149+
150+
withBottomElement(WebElement element); // Verify that element which located bottom to is correct
151+
152+
153+
withBottomElement(WebElement element, int minMargin, int maxMargin); // Verify that element which located bottom to is correct with specified margins
154+
155+
156+
notOverlapWith(WebElement element, String readableName); // Verify that element is NOT overlapped with specified element
157+
158+
159+
overlapWith(WebElement element, String readableName); // Verify that element is overlapped with specified element
160+
161+
162+
notOverlapWith(List<WebElement> elements); // Verify that element is NOT overlapped with every element is the list
163+
164+
165+
sameOffsetLeftAs(WebElement element, String readableName); // Verify that element has the same left offset as specified element
166+
167+
168+
sameOffsetLeftAs(List<WebElement> elements); // Verify that element has the same left offset as every element is the list
169+
170+
171+
sameOffsetRightAs(WebElement element, String readableName); // Verify that element has the same right offset as specified element
172+
173+
174+
sameOffsetRightAs(List<WebElement> elements); // Verify that element has the same right offset as every element is the list
175+
176+
177+
sameOffsetTopAs(WebElement element, String readableName); // Verify that element has the same top offset as specified element
178+
179+
180+
sameOffsetTopAs(List<WebElement> elements); // Verify that element has the same top offset as every element is the list
181+
182+
183+
sameOffsetBottomAs(WebElement element, String readableName); // Verify that element has the same bottom offset as specified element
184+
185+
186+
sameOffsetBottomAs(List<WebElement> elements); // Verify that element has the same bottom offset as every element is the list
187+
188+
189+
sameWidthAs(WebElement element, String readableName); // Verify that element has the same width as specified element
190+
191+
192+
sameWidthAs(List<WebElement> elements); // Verify that element has the same width as every element in the list
193+
194+
195+
minWidth(int width); // Verify that width of element is not less than specified
196+
197+
198+
maxWidth(int width); // Verify that width of element is not bigger than specified
199+
200+
201+
widthBetween(int min, int max); // Verify that width of element is in range
202+
203+
204+
sameHeightAs(WebElement element, String readableName); // Verify that element has the same height as specified element
205+
206+
207+
sameHeightAs(List<WebElement> elements); // Verify that element has the same height as every element in the list
208+
209+
210+
minHeight(int height); // Verify that height of element is not less than specified
211+
212+
213+
maxHeight(int height); // Verify that height of element is not bigger than specified
214+
215+
216+
sameSizeAs(WebElement element, String readableName); // Verify that element has the same size as specified element
217+
218+
219+
sameSizeAs(List<WebElement> elements); // Verify that element has the same size as every element in the list
220+
221+
222+
heightBetween(int min, int max); // Verify that height of element is in range
223+
224+
225+
minOffset(int top, int right, int bottom, int left); // Verify that min offset of element is not less than (min value is -10000)
226+
227+
228+
maxOffset(int top, int right, int bottom, int left); // Verify that max offset of element is not bigger than (min value is -10000)
229+
230+
231+
withCssValue(String cssProperty, String... args); // Verify that element has correct CSS values
232+
233+
234+
withoutCssValue(String cssProperty, String... args); // Verify that concrete CSS values are absent for specified element
235+
236+
237+
equalLeftRightOffset(); // Verify that element has equal left and right offsets (e.g. Bootstrap container)
238+
239+
240+
equalTopBottomOffset(); // Verify that element has equal top and bottom offset (aligned vertically in center)
241+
242+
243+
changeMetricsUnitsTo(ResponsiveUIValidator.Units units); // Change units to Pixels or % (Units.PX, Units.PERCENT)
244+
245+
* For list of elements findElements({element}):
246+
247+
insideOf(WebElement containerElement, String readableContainerName); // Verify that elements are located inside of specified element
248+
249+
alignedAsGrid(int horizontalGridSize); // Verify that elements are aligned in a grid view width specified amount of columns
250+
251+
alignedAsGrid(int horizontalGridSize, int verticalGridSize); // Verify that elements are aligned in a grid view width specified amount of columns and rows
252+
253+
areNotOverlappedWithEachOther(); // Verify that every element in the list is not overlapped with another element from this list
254+
255+
withSameSize(); // Verify that elements in the list have the same size
256+
257+
withSameWidth(); // Verify that elements in the list have the same width
258+
259+
withSameHeight(); // Verify that elements in the list have the same height
260+
261+
sameRightOffset(); // Verify that elements in the list have the right offset
262+
263+
sameLeftOffset(); // Verify that elements in the list have the same left offset
264+
265+
sameTopOffset(); // Verify that elements in the list have the same top offset
266+
267+
sameBottomOffset(); // Verify that elements in the list have the same bottom offset
268+
269+
equalLeftRightOffset(); // Verify that every element in the list have equal right and left offset (aligned horizontally in center)
270+
271+
equalTopBottomOffset(); // Verify that every element in the list have equal top and bottom offset (aligned vertically in center)
272+
273+
changeMetricsUnitsTo(ResponsiveUIValidator.Units units); // Change units to Pixels or % (Units.PX, Units.PERCENT)
274+
275+
* Generating results:
276+
277+
drawMap(); // Methods needs to be called to collect all the results in JSON file and screenshots
278+
279+
validate(); // Call method to summarize and validate the results (can be called with drawMap(). In this case result will be only True or False)
280+
281+
generateReport(); // Call method to generate HTML report
282+
283+
generateReport("file report name"); // Call method to generate HTML report with specified file report name
109284

285+
### Possibilities ###
110286
- Verification that elements are aligned correctly on the web or mobile page
111287
* Elements horizontally are aligned correctly:
112288

src/main/java/util/validator/ResponsiveUIChunkValidator.java

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55

66
import java.util.List;
77

8-
import static environment.EnvironmentFactory.isChrome;
9-
import static util.general.SystemHelper.isRetinaDisplay;
10-
118
public class ResponsiveUIChunkValidator extends ResponsiveUIValidator implements ChunkValidator {
129

1310
ResponsiveUIChunkValidator(WebDriver driver, List<WebElement> elements) {
@@ -19,78 +16,147 @@ public class ResponsiveUIChunkValidator extends ResponsiveUIValidator implements
1916
startTime = System.currentTimeMillis();
2017
}
2118

19+
/**
20+
* Change units to Pixels or % (Units.PX, Units.PERCENT)
21+
*
22+
* @param units
23+
* @return ResponsiveUIChunkValidator
24+
*/
2225
@Override
2326
public ResponsiveUIChunkValidator changeMetricsUnitsTo(Units units) {
2427
this.units = units;
2528
return this;
2629
}
2730

31+
/**
32+
* Verify that elements are aligned in a grid view width specified amount of columns
33+
*
34+
* @param horizontalGridSize
35+
* @return ResponsiveUIChunkValidator
36+
*/
2837
@Override
2938
public ResponsiveUIChunkValidator alignedAsGrid(int horizontalGridSize) {
3039
validateGridAlignment(horizontalGridSize, 0);
3140
return this;
3241
}
3342

43+
/**
44+
* Verify that elements are aligned in a grid view width specified amount of columns and rows
45+
*
46+
* @param horizontalGridSize
47+
* @param verticalGridSize
48+
* @return ResponsiveUIChunkValidator
49+
*/
3450
@Override
3551
public ResponsiveUIChunkValidator alignedAsGrid(int horizontalGridSize, int verticalGridSize) {
3652
validateGridAlignment(horizontalGridSize, verticalGridSize);
3753
return this;
3854
}
3955

56+
/**
57+
* Verify that every element in the list is not overlapped with another element from this list
58+
*
59+
* @return ResponsiveUIChunkValidator
60+
*/
4061
@Override
4162
public ResponsiveUIChunkValidator areNotOverlappedWithEachOther() {
4263
validateElementsAreNotOverlapped(rootElements);
4364
return this;
4465
}
4566

67+
/**
68+
* Verify that elements in the list have the same size
69+
*
70+
* @return ResponsiveUIChunkValidator
71+
*/
4672
@Override
4773
public ResponsiveUIChunkValidator withSameSize() {
4874
validateSameSize(rootElements, 0);
4975
return this;
5076
}
5177

78+
/**
79+
* Verify that elements in the list have the same width
80+
*
81+
* @return ResponsiveUIChunkValidator
82+
*/
5283
@Override
5384
public ResponsiveUIChunkValidator withSameWidth() {
5485
validateSameSize(rootElements, 1);
5586
return this;
5687
}
5788

89+
/**
90+
* Verify that elements in the list have the same height
91+
*
92+
* @return ResponsiveUIChunkValidator
93+
*/
5894
@Override
5995
public ResponsiveUIChunkValidator withSameHeight() {
6096
validateSameSize(rootElements, 2);
6197
return this;
6298
}
6399

100+
/**
101+
* Verify that elements in the list have the right offset
102+
*
103+
* @return ResponsiveUIChunkValidator
104+
*/
64105
@Override
65106
public ResponsiveUIChunkValidator sameRightOffset() {
66107
validateRightOffsetForChunk(rootElements);
67108
return this;
68109
}
69110

111+
/**
112+
* Verify that elements in the list have the same left offset
113+
*
114+
* @return ResponsiveUIChunkValidator
115+
*/
70116
@Override
71117
public ResponsiveUIChunkValidator sameLeftOffset() {
72118
validateLeftOffsetForChunk(rootElements);
73119
return this;
74120
}
75121

122+
/**
123+
* Verify that elements in the list have the same top offset
124+
*
125+
* @return ResponsiveUIChunkValidator
126+
*/
76127
@Override
77128
public ResponsiveUIChunkValidator sameTopOffset() {
78129
validateTopOffsetForChunk(rootElements);
79130
return this;
80131
}
81132

133+
/**
134+
* Verify that elements in the list have the same bottom offset
135+
*
136+
* @return ResponsiveUIChunkValidator
137+
*/
82138
@Override
83139
public ResponsiveUIChunkValidator sameBottomOffset() {
84140
validateBottomOffsetForChunk(rootElements);
85141
return this;
86142
}
87143

144+
/**
145+
* Verify that every element in the list have equal right and left offset (aligned horizontally in center)
146+
*
147+
* @return ResponsiveUIChunkValidator
148+
*/
88149
@Override
89150
public ResponsiveUIChunkValidator equalLeftRightOffset() {
90151
validateEqualLeftRightOffset(rootElements);
91152
return this;
92153
}
93154

155+
/**
156+
* Verify that every element in the list have equal top and bottom offset (aligned vertically in center)
157+
*
158+
* @return ResponsiveUIChunkValidator
159+
*/
94160
@Override
95161
public ResponsiveUIChunkValidator equalTopBottomOffset() {
96162
validateEqualTopBottomOffset(rootElements);

0 commit comments

Comments
 (0)