java - Image position using safari driver in selenium -


i'm trying make screen capture of web page , retrieve size , location of image , finaly save image in file.

snippet:

this.driver.navigate().to(xxx);  final byte[] arrscreen = ((takesscreenshot) this.driver).getscreenshotas(outputtype.bytes); final bufferedimage imagescreen = imageio.read(new bytearrayinputstream(arrscreen)); final webelement cap = this.driver.findelement(by.id("myimageid"));  final dimension capdimension = cap.getsize(); final point caplocation = cap.getlocation(); final bufferedimage imgcap = imagescreen.getsubimage(caplocation.x, caplocation.y,             capdimension.width, capdimension.height);  final file file = new file(".../capture.png"); final fileoutputstream os = new fileoutputstream(file); imageio.write(imgcap, "png", os); 

this work fine using windows os (chromedriver) doesn't work (the coordinates wrong) using mac os (chromedriver , safaridriver both fail).

any idea why ?

edit:

is there difference between takesscreenshot in windows , mac os ?

i replaced :

final bufferedimage imgcap = imagescreen.getsubimage(caplocation.x, caplocation.y,         capdimension.width, capdimension.height); 

with , works :

final bufferedimage imgcap = imagescreen.getsubimage(caplocation.x * 2, caplocation.y * 2,         capdimension.width * 2, capdimension.height * 2); 

but still don't know why, idea ?


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -