Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Create a feature branch and start improving:
% git checkout -b my-feature-branch
```

HEAD-based development is prefered, which means all changes are applied
HEAD-based development is preferred, which means all changes are applied
directly on top of master.

### Step 3: Commit
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Selenium Shutterbug is a utility library written in Java for making screenshots

## Code Example

Screenhot of the page with scrolling (for Chrome to make screenshot of the whole page but not viewport only):
Screenshot of the page with scrolling (for Chrome to make screenshot of the whole page but not viewport only):
```
Shutterbug.shootPage(driver, ScrollStrategy.BOTH_DIRECTIONS).save("C:\\testing\\screenshots\\");
```
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.assertthat.selenium_shutterbug.utils.web.Coordinates;
import com.assertthat.selenium_shutterbug.utils.web.ElementOutsideViewportException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.awt.image.BufferedImage;
import java.awt.image.RasterFormatException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

package com.assertthat.selenium_shutterbug.core;

import com.assertthat.selenium_shutterbug.utils.web.ElementOutsideViewportException;
import com.assertthat.selenium_shutterbug.utils.image.ImageProcessor;
import com.assertthat.selenium_shutterbug.utils.web.Coordinates;
import com.assertthat.selenium_shutterbug.utils.web.ElementOutsideViewportException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

Expand Down
31 changes: 20 additions & 11 deletions src/main/java/com/assertthat/selenium_shutterbug/core/Snapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public T withTitle(String title) {
* @return instance of type Snapshot
*/
public T withThumbnail(String path, String name, double scale) {
File thumbnailFile = new File(path.toString(), name);
File thumbnailFile = new File(path, name);
if(!Files.exists(Paths.get(path))) {
thumbnailFile.mkdirs();
}
Expand All @@ -90,15 +90,12 @@ public T withThumbnail(String path, String name, double scale) {
* @return instance of type Snapshot
*/
public T withCroppedThumbnail(String path, String name, double scale, double cropWidth, double cropHeight) {
File thumbnailFile = new File(path.toString(), name);
if(!Files.exists(Paths.get(path))) {
thumbnailFile.mkdirs();
}
File thumbnailFile = getFile(path, name);
thumbnailImage=ImageProcessor.cropAndScale(image,scale, cropWidth, cropHeight);
FileUtil.writeImage(thumbnailImage, EXTENSION, thumbnailFile);
return self();
}

/**
* Generate cropped thumbnail of the original screenshot.
* Will save different thumbnails depends on when it was called in the chain.
Expand All @@ -111,15 +108,27 @@ public T withCroppedThumbnail(String path, String name, double scale, double cr
* @return instance of type Snapshot
*/
public T withCroppedThumbnail(String path, String name, double scale, int maxWidth, int maxHeight) {
File thumbnailFile = new File(path.toString(), name);
if(!Files.exists(Paths.get(path))) {
thumbnailFile.mkdirs();
}
File thumbnailFile = getFile(path, name);
thumbnailImage=ImageProcessor.cropAndScale(image,scale, maxWidth, maxHeight);
FileUtil.writeImage(thumbnailImage, EXTENSION, thumbnailFile);
return self();
}


/**
* Generate file for cropped thumbnail of the original screenshot.
*
* @param path to save thumbnail image to
* @param name of the resulting image
* @return instance of type File
*/
private File getFile(String path, String name) {
File thumbnailFile = new File(path, name);
if (!Files.exists(Paths.get(path))) {
thumbnailFile.mkdirs();
}
return thumbnailFile;
}

/**
* Generate cropped thumbnail of the original screenshot.
* Will save different thumbnails depends on when it was called in the chain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static String getJsScript(String filePath) {
try {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
if (is == null) {
// This is needed to load the files in an OSGI enviroment when enclosed in a bundle
// This is needed to load the files in an OSGI environment when enclosed in a bundle
is = FileUtil.class.getClassLoader().getResourceAsStream(filePath);
}
// if the input stream is still null, this will avoid a non descriptive null pointer exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package com.assertthat.selenium_shutterbug.utils.file;

import org.openqa.selenium.WebDriverException;

/**
* Created by Glib_Briia on 17/06/2016.
*/
Expand Down
Loading