Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ public class Shutterbug {
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver) {
return shootPage(driver,false);
return shootPage(driver, true);
}

/**
* Make screen shot of the viewport only.
* To be used when screen shooting the page
* and don't need to scroll while making screen shots (FF, IE).
*
* @param driver WebDriver instance
* @param driver WebDriver instance
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver, boolean useDevicePixelRatio) {
Browser browser = new Browser(driver, useDevicePixelRatio);
PageSnapshot pageScreenshot = new PageSnapshot(driver,browser.getDevicePixelRatio());
PageSnapshot pageScreenshot = new PageSnapshot(driver, browser.getDevicePixelRatio());
pageScreenshot.setImage(browser.takeScreenshot());
return pageScreenshot;
}
Expand All @@ -63,84 +63,84 @@ public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll) {
* and need to scroll while making screen shots, either vertically or
* horizontally or both directions (Chrome).
*
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param betweenScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param betweenScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll, int betweenScrollTimeout) {
return shootPage(driver,scroll,betweenScrollTimeout,false);
return shootPage(driver, scroll, betweenScrollTimeout, true);
}

/**
* To be used when screen shooting the page
* and need to scroll while making screen shots, either vertically or
* horizontally or both directions (Chrome).
*
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param betweenScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @param afterScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param betweenScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @param afterScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll, int betweenScrollTimeout, int afterScrollTimeout) {
return shootPage(driver,scroll,betweenScrollTimeout,false, afterScrollTimeout);
return shootPage(driver, scroll, betweenScrollTimeout, true, afterScrollTimeout);
}

/**
* To be used when screen shooting the page
* and need to scroll while making screen shots, either vertically or
* horizontally or both directions (Chrome).
*
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll, boolean useDevicePixelRatio) {
return shootPage(driver,scroll,0,useDevicePixelRatio);
return shootPage(driver, scroll, 0, useDevicePixelRatio);
}

/**
* To be used when screen shooting the page
* and need to scroll while making screen shots, either vertically or
* horizontally or both directions (Chrome).
*
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @param afterScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @param afterScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll, boolean useDevicePixelRatio, int afterScrollTimeout) {
return shootPage(driver,scroll,0,useDevicePixelRatio, afterScrollTimeout);
return shootPage(driver, scroll, 0, useDevicePixelRatio, afterScrollTimeout);
}

/**
* To be used when screen shooting the page
* and need to scroll while making screen shots, either vertically or
* horizontally or both directions (Chrome).
*
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param betweenScrollTimeout Timeout to wait between each scrolling operation
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param betweenScrollTimeout Timeout to wait between each scrolling operation
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll, int betweenScrollTimeout, boolean useDevicePixelRatio) {
return shootPage(driver,scroll,betweenScrollTimeout,useDevicePixelRatio,0);
return shootPage(driver, scroll, betweenScrollTimeout, useDevicePixelRatio, 0);
}

/**
* To be used when screen shooting the page
* and need to scroll while making screen shots, either vertically or
* horizontally or both directions (Chrome).
*
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param betweenScrollTimeout Timeout to wait between each scrolling operation
* @param afterScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @param driver WebDriver instance
* @param scroll ScrollStrategy How you need to scroll
* @param betweenScrollTimeout Timeout to wait between each scrolling operation
* @param afterScrollTimeout Timeout to wait after scrolling and before taking screenshot
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @return PageSnapshot instance
*/
public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll, int betweenScrollTimeout, boolean useDevicePixelRatio, int afterScrollTimeout) {
Expand Down Expand Up @@ -168,9 +168,9 @@ public static PageSnapshot shootPage(WebDriver driver, ScrollStrategy scroll, in
* @return ElementSnapshot instance
*/
public static ElementSnapshot shootElementVerticallyCentered(WebDriver driver, WebElement element) {
return shootElementVerticallyCentered(driver,element,false);
return shootElementVerticallyCentered(driver, element, true);
}

/**
* To be used when need to screenshot particular element.
*
Expand All @@ -179,39 +179,38 @@ public static ElementSnapshot shootElementVerticallyCentered(WebDriver driver, W
* @return ElementSnapshot instance
*/
public static ElementSnapshot shootElement(WebDriver driver, WebElement element) {
return shootElement(driver,element,false);
return shootElement(driver, element, true);
}

/**
* To be used when need to screenshot particular element.
*
* @param driver WebDriver instance
* @param element WebElement instance to be screen shot
* @param driver WebDriver instance
* @param element WebElement instance to be screen shot
* @param useDevicePixelRatio whether or not take into account device pixel ratio
* @return ElementSnapshot instance
*/
public static ElementSnapshot shootElement(WebDriver driver, WebElement element, boolean useDevicePixelRatio) {
Browser browser = new Browser(driver, useDevicePixelRatio);
ElementSnapshot elementSnapshot = new ElementSnapshot(driver, browser.getDevicePixelRatio());
browser.scrollToElement(element);
elementSnapshot.setImage(browser.takeScreenshot(),browser.getBoundingClientRect(element));
elementSnapshot.setImage(browser.takeScreenshot(), browser.getBoundingClientRect(element));
return elementSnapshot;
}

/**
* To be used when need to screenshot particular element by vertically centering it within viewport.
*
* @param driver WebDriver instance
* @param element WebElement instance to be screen shot
* @param driver WebDriver instance
* @param element WebElement instance to be screen shot
* @param useDevicePixelRatio whether or not take into account device pixel ratio
*
* @return ElementSnapshot instance
*/
public static ElementSnapshot shootElementVerticallyCentered(WebDriver driver, WebElement element, boolean useDevicePixelRatio) {
Browser browser = new Browser(driver, useDevicePixelRatio);
ElementSnapshot elementSnapshot = new ElementSnapshot(driver, browser.getDevicePixelRatio());
browser.scrollToElementVerticalCentered(element);
elementSnapshot.setImage(browser.takeScreenshot(),browser.getBoundingClientRect(element));
elementSnapshot.setImage(browser.takeScreenshot(), browser.getBoundingClientRect(element));
return elementSnapshot;
}
}