Created
May 24, 2013 10:35
-
-
Save zevnull/5642632 to your computer and use it in GitHub Desktop.
Element screenshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BrowserFactory.getExistentWebDriver().switchTo().frame( "outerFrame" ); | |
WebElement ele = | |
BrowserFactory.getExistentWebDriver().findElement( By.cssSelector( "canvas.flot-overlay" ) ); | |
File screenshot = ( ( TakesScreenshot ) BrowserFactory.getExistentWebDriver() ).getScreenshotAs( OutputType.FILE ); | |
BufferedImage fullImg = ImageIO.read( screenshot ); | |
Point point = ele.getLocation(); | |
int eleWidth = ele.getSize().getWidth(); | |
int eleHeight = ele.getSize().getHeight(); | |
BufferedImage eleScreenshot = fullImg.getSubimage( point.getX(), point.getY(), eleWidth, eleHeight ); | |
ImageIO.write( eleScreenshot, "png", screenshot ); | |
FileUtils.copyFile( screenshot, new File( "elementScreenshot66.png" ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment