Skip to content

Commit 40689b9

Browse files
committed
Add ecxeption on saving screenshot; refactor names
1 parent 5f2f57d commit 40689b9

File tree

4 files changed

+52
-10
lines changed

4 files changed

+52
-10
lines changed

src/main/java/com/assertthat/selenium_shutterbug/utils/file/FileUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.assertthat.selenium_shutterbug.utils.file;
1818

1919

20-
import com.assertthat.selenium_shutterbug.utils.web.UnableTakeScreenshotException;
20+
import com.assertthat.selenium_shutterbug.utils.web.UnableTakeSnapshotException;
2121
import org.apache.commons.io.IOUtils;
2222

2323
import javax.imageio.ImageIO;
@@ -34,15 +34,15 @@ public static String getJsScript(String filePath) {
3434
try {
3535
return IOUtils.toString(Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath));
3636
} catch (IOException e) {
37-
throw new UnableTakeScreenshotException("Unable to load JS script", e);
37+
throw new UnableTakeSnapshotException("Unable to load JS script", e);
3838
}
3939
}
4040

4141
public static void writeImage(BufferedImage imageFile, String extension, File fileToWriteTo) {
4242
try {
4343
ImageIO.write(imageFile, extension, fileToWriteTo);
4444
} catch (IOException e) {
45-
throw new UnableTakeScreenshotException(e);
45+
throw new UnableSaveSnapshotException(e);
4646
}
4747
}
4848
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2016 Glib Briia
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package com.assertthat.selenium_shutterbug.utils.file;
19+
20+
import org.openqa.selenium.WebDriverException;
21+
22+
/**
23+
* Created by Glib_Briia on 17/06/2016.
24+
*/
25+
public class UnableSaveSnapshotException extends RuntimeException {
26+
27+
public UnableSaveSnapshotException() {
28+
super();
29+
}
30+
31+
public UnableSaveSnapshotException(String message) {
32+
super(message);
33+
}
34+
35+
public UnableSaveSnapshotException(Throwable cause) {
36+
super(cause);
37+
}
38+
39+
public UnableSaveSnapshotException(String message, Throwable cause) {
40+
super(message, cause);
41+
}
42+
}

src/main/java/com/assertthat/selenium_shutterbug/utils/web/Browser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static void wait(int milis) {
5959
try {
6060
Thread.sleep(milis);
6161
} catch (InterruptedException e) {
62-
throw new UnableTakeScreenshotException(e);
62+
throw new UnableTakeSnapshotException(e);
6363
}
6464
}
6565

@@ -68,7 +68,7 @@ public BufferedImage takeScreenshot() {
6868
try {
6969
return ImageIO.read(srcFile);
7070
} catch (IOException e) {
71-
throw new UnableTakeScreenshotException(e);
71+
throw new UnableTakeSnapshotException(e);
7272
}
7373
}
7474

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
/**
2222
* Created by Glib_Briia on 17/06/2016.
2323
*/
24-
public class UnableTakeScreenshotException extends WebDriverException {
24+
public class UnableTakeSnapshotException extends WebDriverException {
2525

26-
public UnableTakeScreenshotException() {
26+
public UnableTakeSnapshotException() {
2727
super();
2828
}
2929

30-
public UnableTakeScreenshotException(String message) {
30+
public UnableTakeSnapshotException(String message) {
3131
super(message);
3232
}
3333

34-
public UnableTakeScreenshotException(Throwable cause) {
34+
public UnableTakeSnapshotException(Throwable cause) {
3535
super(cause);
3636
}
3737

38-
public UnableTakeScreenshotException(String message, Throwable cause) {
38+
public UnableTakeSnapshotException(String message, Throwable cause) {
3939
super(message, cause);
4040
}
4141
}

0 commit comments

Comments
 (0)