Skip to content

Commit 4604511

Browse files
committed
Refactor for cutting out multiple elements at a time
1 parent 31d0730 commit 4604511

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/main/java/com/assertthat/selenium_shutterbug/core/PageSnapshot.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,29 +176,33 @@ public PageSnapshot cropAround(WebElement element, int offsetX, int offsetY) {
176176
/**
177177
* Cut out specified element with offset.
178178
*
179-
* @param element WebElement to crop
179+
* @param elements WebElement to crop
180180
* @param offsetX offsetX around element in px
181181
* @param offsetY offsetY around element in px
182182
* @return instance of type PageSnapshot
183183
*/
184-
public PageSnapshot cutOut(WebElement element, int offsetX, int offsetY) {
184+
public PageSnapshot cutOut(int offsetX, int offsetY, WebElement... elements) {
185185
try {
186-
image = ImageProcessor.cutOut(image, new Coordinates(element, devicePixelRatio), offsetX, offsetY);
186+
for (WebElement element : elements) {
187+
ImageProcessor.cutOut(image, new Coordinates(element, devicePixelRatio), offsetX, offsetY);
188+
}
187189
} catch (RasterFormatException rfe) {
188190
throw new ElementOutsideViewportException(ELEMENT_OUT_OF_VIEWPORT_EX_MESSAGE, rfe);
189191
}
190192
return this;
191193
}
192194

193195
/**
194-
* Cut out specified element.
196+
* Cut out specified element(s).
195197
*
196-
* @param element WebElement to crop
198+
* @param elements WebElement to crop
197199
* @return instance of type PageSnapshot
198200
*/
199-
public PageSnapshot cutOut(WebElement element) {
201+
public PageSnapshot cutOut(WebElement... elements) {
200202
try {
201-
image = ImageProcessor.cutOut(image, new Coordinates(element, devicePixelRatio), 0, 0);
203+
for (WebElement element : elements) {
204+
ImageProcessor.cutOut(image, new Coordinates(element, devicePixelRatio), 0, 0);
205+
}
202206
} catch (RasterFormatException rfe) {
203207
throw new ElementOutsideViewportException(ELEMENT_OUT_OF_VIEWPORT_EX_MESSAGE, rfe);
204208
}

0 commit comments

Comments
 (0)