@@ -61,9 +61,9 @@ public class Browser {
6161
6262 public Browser (WebDriver driver , boolean useDevicePixelRatio ) {
6363 this .driver = driver ;
64- if (useDevicePixelRatio ) {
64+ if (useDevicePixelRatio ) {
6565 Object devicePixelRatio = executeJsScript (DEVICE_PIXEL_RATIO );
66- this .devicePixelRatio = devicePixelRatio instanceof Double ? (Double )devicePixelRatio : (Long )devicePixelRatio * 1.0 ;
66+ this .devicePixelRatio = devicePixelRatio instanceof Double ? (Double ) devicePixelRatio : (Long ) devicePixelRatio * 1.0 ;
6767 }
6868 }
6969
@@ -79,7 +79,7 @@ public static void wait(int ms) {
7979 }
8080 }
8181
82- public void setScrollTimeout (int scrollTimeout ){
82+ public void setScrollTimeout (int scrollTimeout ) {
8383 this .scrollTimeout = scrollTimeout ;
8484 }
8585
@@ -90,19 +90,21 @@ public BufferedImage takeScreenshot() {
9090 } catch (IOException e ) {
9191 throw new UnableTakeSnapshotException (e );
9292 } finally {
93- // add this to clean up leaving this file in the temporary directory forever...
94- if (srcFile .exists ()) {
95- srcFile .delete ();
96- }
97- }
93+ // add this to clean up leaving this file in the temporary directory forever...
94+ if (srcFile .exists ()) {
95+ srcFile .delete ();
96+ }
97+ }
9898
9999 }
100100
101- /**Using different screenshot strategy dependently on driver:
101+ /**
102+ * Using different screenshot strategy dependently on driver:
102103 * for chrome - chrome command will be used
103104 * for others - their default screenshot methods
105+ *
104106 * @return BufferedImage resulting image
105- * * /
107+ */
106108 public BufferedImage takeScreenshotEntirePage () {
107109 if (driver instanceof EventFiringWebDriver ) {
108110 driver = ((EventFiringWebDriver ) this .driver ).getWrappedDriver ();
@@ -120,8 +122,8 @@ public BufferedImage takeScreenshotEntirePage() {
120122
121123 public BufferedImage takeScreenshotEntirePageDefault () {
122124 final int _docWidth = this .getDocWidth ();
123- final int _docHeight = this .getDocHeight ();
124- BufferedImage combinedImage = new BufferedImage (_docWidth , _docHeight , BufferedImage .TYPE_INT_ARGB );
125+ final int _docHeight = this .getDocHeight ();
126+ BufferedImage combinedImage = new BufferedImage (_docWidth , _docHeight , BufferedImage .TYPE_INT_ARGB );
125127 Graphics2D g = combinedImage .createGraphics ();
126128 int _viewportWidth = this .getViewportWidth ();
127129 int _viewportHeight = this .getViewportHeight ();
@@ -130,10 +132,10 @@ public BufferedImage takeScreenshotEntirePageDefault() {
130132 if (_viewportWidth < _docWidth || (_viewportHeight < _docHeight && _viewportWidth - scrollBarMaxWidth < _docWidth ))
131133 _viewportHeight -= scrollBarMaxWidth ; // some space for a scrollbar // TODO viewportHeight and scrollVarMaxWidth?
132134 if (_viewportHeight < _docHeight )
133- _viewportWidth -= scrollBarMaxWidth ; // some space for a scrollbar
135+ _viewportWidth -= scrollBarMaxWidth ; // some space for a scrollbar
134136
135- int horizontalIterations = (int ) Math .ceil (((double ) _docWidth ) / _viewportWidth );
136- int verticalIterations = (int ) Math .ceil (((double ) _docHeight ) / _viewportHeight );
137+ int horizontalIterations = (int ) Math .ceil (((double ) _docWidth ) / _viewportWidth );
138+ int verticalIterations = (int ) Math .ceil (((double ) _docHeight ) / _viewportHeight );
137139 outer_loop :
138140 for (int j = 0 ; j < verticalIterations ; j ++) {
139141 this .scrollTo (0 , j * _viewportHeight );
@@ -142,7 +144,7 @@ public BufferedImage takeScreenshotEntirePageDefault() {
142144 wait (scrollTimeout );
143145 Image image = takeScreenshot ();
144146 g .drawImage (image , this .getCurrentScrollX (), this .getCurrentScrollY (), null );
145- if (_docWidth == image .getWidth (null ) && _docHeight == image .getHeight (null )){
147+ if (_docWidth == image .getWidth (null ) && _docHeight == image .getHeight (null )) {
146148 break outer_loop ;
147149 }
148150 }
@@ -154,7 +156,7 @@ public BufferedImage takeScreenshotEntirePageDefault() {
154156 public BufferedImage takeScreenshotEntirePageUsingChromeCommand () {
155157 //should use devicePixelRatio by default as chrome command executor makes screenshot account for that
156158 Object devicePixelRatio = executeJsScript (DEVICE_PIXEL_RATIO );
157- this .devicePixelRatio = devicePixelRatio instanceof Double ? (Double )devicePixelRatio : (Long )devicePixelRatio * 1.0 ;
159+ this .devicePixelRatio = devicePixelRatio instanceof Double ? (Double ) devicePixelRatio : (Long ) devicePixelRatio * 1.0 ;
158160
159161 try {
160162 CommandInfo cmd = new CommandInfo ("/session/:sessionId/chromium/send_command_and_get_result" , HttpMethod .POST );
@@ -190,11 +192,11 @@ public WebDriver getUnderlyingDriver() {
190192 }
191193
192194 public int getCurrentScrollX () {
193- return (int )(((Long ) executeJsScript (Browser .CURRENT_SCROLL_X_JS ))* devicePixelRatio );
195+ return (int ) (((Long ) executeJsScript (Browser .CURRENT_SCROLL_X_JS )) * devicePixelRatio );
194196 }
195197
196198 public int getCurrentScrollY () {
197- return (int )(((Long ) executeJsScript (Browser .CURRENT_SCROLL_Y_JS ))* devicePixelRatio );
199+ return (int ) (((Long ) executeJsScript (Browser .CURRENT_SCROLL_Y_JS )) * devicePixelRatio );
198200 }
199201
200202 public int getDocWidth () {
@@ -231,7 +233,7 @@ public void scrollToElement(WebElement element) {
231233 }
232234
233235 public void scrollTo (int x , int y ) {
234- executeJsScript (SCROLL_TO_JS , x / devicePixelRatio , y / devicePixelRatio );
236+ executeJsScript (SCROLL_TO_JS , x / devicePixelRatio , y / devicePixelRatio );
235237 }
236238
237239 public Object executeJsScript (String filePath , Object ... arg ) {
0 commit comments