Skip to content

Commit 6535c21

Browse files
committed
Add javadoc; fix typo
1 parent 7164e9b commit 6535c21

File tree

2 files changed

+67
-43
lines changed

2 files changed

+67
-43
lines changed

src/main/java/com/assertthat/selenium_screenshotter/core/PageScreenshot.java

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,57 @@ public class PageScreenshot extends Screenshot<PageScreenshot> {
1717
}
1818

1919
/**
20-
* @param element
21-
* @return
20+
* Highlights WebElement within the page with Color.red
21+
* and line width 3.
22+
*
23+
* @param element WebElement to be highlighted
24+
* @return instance of type PageScreenshot
2225
*/
2326
public PageScreenshot highlight(WebElement element) {
2427
highlight(element, Color.red, 3);
2528
return this;
2629
}
2730

2831
/**
29-
* @param element
30-
* @param color
31-
* @param lineWidth
32-
* @return
32+
* Highlights WebElement within the page with provided color
33+
* and line width.
34+
*
35+
* @param element WebElement to be highlighted
36+
* @param color color of the line
37+
* @param lineWidth width of the line
38+
* @return instance of type PageScreenshot
3339
*/
3440
public PageScreenshot highlight(WebElement element, Color color, int lineWidth) {
3541
image = ImageProcessor.highlight(image, new Coordinates(element), color, lineWidth);
3642
return this;
3743
}
3844

3945
/**
40-
* @param element
41-
* @param text
42-
* @return
46+
* Highlight WebElement within the page (same as in {@link #highlight(WebElement)}}
47+
* and adding provided text above highlighted element.
48+
*
49+
* @param element WebElement to be highlighted with Color.red
50+
* and line width 3
51+
* @param text test to be places above highlighted element with
52+
* Color.red, font "Serif", BOLD, size 20
53+
* @return instance of type PageScreenshot
4354
*/
4455
public PageScreenshot highlightWithText(WebElement element, String text) {
4556
highlightWithText(element, Color.red, 3, text, Color.red, new Font("Serif", Font.BOLD, 20));
4657
return this;
4758
}
4859

4960
/**
50-
* @param element
51-
* @param elementColor
52-
* @param lineWidth
53-
* @param text
54-
* @param textColor
55-
* @param textFont
56-
* @return
61+
* Highlight WebElement within the page, same as in {@link #highlight(WebElement)}
62+
* but providing ability to override default color, font values.
63+
*
64+
* @param element WebElement to be highlighted
65+
* @param elementColor element highlight color
66+
* @param lineWidth line width around the element
67+
* @param text text to be placed above the highlighted element
68+
* @param textColor color of the text
69+
* @param textFont text font
70+
* @return instance of type PageScreenshot
5771
*/
5872
public PageScreenshot highlightWithText(WebElement element, Color elementColor, int lineWidth, String text, Color textColor, Font textFont) {
5973
highlight(element, elementColor, 0);
@@ -63,34 +77,43 @@ public PageScreenshot highlightWithText(WebElement element, Color elementColor,
6377
}
6478

6579
/**
66-
* @return
80+
* Blur the entire page.
81+
*
82+
* @return instance of type PageScreenshot
6783
*/
6884
public PageScreenshot blur() {
6985
image = ImageProcessor.blur(image);
7086
return this;
7187
}
7288

7389
/**
74-
* @param element
75-
* @return
90+
* Blur provided element within the page only.
91+
*
92+
* @param element WebElement to be blurred
93+
* @return instance of type PageScreenshot
7694
*/
7795
public PageScreenshot blur(WebElement element) {
7896
image = ImageProcessor.blurArea(image, new Coordinates(element));
7997
return this;
8098
}
8199

82100
/**
83-
* @param element
84-
* @return
101+
* Makes an element withing a page 'monochrome' - applies gray-and-white filter.
102+
* Original colors remain on the rest of the page.
103+
*
104+
* @param element WebElement within the page to be made 'monochrome'
105+
* @return instance of type PageScreenshot
85106
*/
86107
public PageScreenshot monochrome(WebElement element) {
87108
image = ImageProcessor.monochromeArea(image, new Coordinates(element));
88109
return this;
89110
}
90111

91112
/**
92-
* @param element
93-
* @return
113+
* Blurs all the page except the element provided.
114+
*
115+
* @param element WebElement to stay not blurred
116+
* @return instance of type PageScreenshot
94117
*/
95118
public PageScreenshot blurExcept(WebElement element) {
96119
image = ImageProcessor.blurExceptArea(image, new Coordinates(element));

src/main/java/com/assertthat/selenium_screenshotter/core/Screenshot.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ public abstract class Screenshot<T extends Screenshot<T>> {
3030
private String title;
3131

3232
/**
33-
* Make screenshot of the viewport only
34-
* <p>
33+
* Make screenshot of the viewport only.
3534
* To be used when screenshotting the page
36-
* and don't need to scroll while making screenshots (FF, IE)
35+
* and don't need to scroll while making screenshots (FF, IE).
3736
*
3837
* @param driver WebDriver instance
3938
* @return PageScreenshot instance
@@ -48,7 +47,7 @@ public static PageScreenshot page(WebDriver driver) {
4847
/**
4948
* To be used when screenshotting the page
5049
* and need to scroll while making screenshots, either vertically or
51-
* horizontally or both directions (Chrome)
50+
* horizontally or both directions (Chrome).
5251
*
5352
* @param driver WebDriver instance
5453
* @param scroll ScrollStrategy How you need to scroll
@@ -71,7 +70,7 @@ public static PageScreenshot page(WebDriver driver, ScrollStrategy scroll) {
7170
}
7271

7372
/**
74-
* To be used when need to screenshot particular element
73+
* To be used when need to screenshot particular element.
7574
*
7675
* @param driver WebDriver instance
7776
* @param element WebElement instance to be screenshotted
@@ -90,7 +89,7 @@ public static ElementScreenshot element(WebDriver driver, WebElement element) {
9089

9190
/**
9291
* @param name file name of the resulted image
93-
* by default will be timestamp in format: 'yyyy_MM_dd_HH_mm_ss_SSS'
92+
* by default will be timestamp in format: 'yyyy_MM_dd_HH_mm_ss_SSS'.
9493
* @return instance of type Screenshot
9594
*/
9695
public T withName(String name) {
@@ -102,7 +101,7 @@ public T withName(String name) {
102101

103102
/**
104103
* @param title title of the resulted image.
105-
* Won't be assigned by default
104+
* Won't be assigned by default.
106105
* @return instance of type Screenshot
107106
*/
108107
public T withTitle(String title) {
@@ -111,7 +110,7 @@ public T withTitle(String title) {
111110
}
112111

113112
/**
114-
* Apply gray-and-white filter to the image
113+
* Apply gray-and-white filter to the image.
115114
*
116115
* @return instance of type Screenshot
117116
*/
@@ -121,7 +120,7 @@ public T monochrome() {
121120
}
122121

123122
/**
124-
* @return
123+
* @return BufferedImage - current image being processed.
125124
*/
126125
public BufferedImage getImage() {
127126
return image;
@@ -133,7 +132,7 @@ protected void setImage(BufferedImage image) {
133132

134133
/**
135134
* Final method to be called in the chain.
136-
* Actually saves processed image.
135+
* Actually saves processed image to the default location: ./screenshots
137136
*/
138137
public void save() {
139138
File screenshotFile = new File(location.toString(), fileName);
@@ -145,7 +144,7 @@ public void save() {
145144

146145
/**
147146
* Final method to be called in the chain.
148-
* Actually saves processed image.
147+
* Actually saves processed image to the specified path.
149148
*/
150149
public void save(String location) {
151150
File screenshotFile = new File(location, fileName);
@@ -157,7 +156,7 @@ public void save(String location) {
157156

158157
/**
159158
* Final method to be called in the chain.
160-
* Actually saves processed image.
159+
* Actually saves processed image to the specified path.
161160
*/
162161
public void save(Path location) {
163162
File screenshotFile = new File(location.toString(), fileName);
@@ -182,8 +181,9 @@ public boolean equals(Object o, double deviation) {
182181
}
183182

184183
/**
185-
* @param o
186-
* @return
184+
* @param o Object to compare with
185+
* @return true if the the provided object is of type Screenshot
186+
* and images are strictly equal.
187187
*/
188188
@Override
189189
public boolean equals(Object o) {
@@ -196,22 +196,23 @@ public boolean equals(Object o) {
196196
}
197197

198198
/**
199-
* @param image
200-
* @return
199+
* @param image BufferedImage to compare with.
200+
* @return true if the the provided image and current image are strictly equal.
201201
*/
202202
public boolean equals(BufferedImage image) {
203203
if (this.getImage() == image) return true;
204204
return getImage() != null ? ImageProcessor.imagesAreEquals(getImage(), image, 0) : image == null;
205205
}
206206

207207
/**
208-
* @param image
209-
* @param deviation
210-
* @return
208+
* @param image BufferedImage to compare with.
209+
* @param deviation allowed deviation while comparing.
210+
* @return true if the the percentage of differences
211+
* between current image and provided one is less than or equal to <b>deviation</b>
211212
*/
212213
public boolean equals(BufferedImage image, double deviation) {
213214
if (this.getImage() == image) return true;
214-
return getImage() != null ? ImageProcessor.imagesAreEquals(getImage(), image, 0) : image == null;
215+
return getImage() != null ? ImageProcessor.imagesAreEquals(getImage(), image, deviation) : image == null;
215216
}
216217

217218
/**

0 commit comments

Comments
 (0)