public void saveImages ( Element form ) throws IOException { List < Element > images = DomUtils . getElementsByTagName ( form , "img" ) ; int imageCount = 1 ; for ( Element image : images ) { if ( image . hasAttribute ( "src" ) ) { String src = image . getAttribute ( "src" ) ; String imageFormat = parseImageFormat ( src ) ; String testName = System . getProperty ( "TestName" ) ; String imgName = parseImageName ( testName ) ; URL url = new URL ( src ) ; BufferedImage img = ImageIO . read ( url ) ; File file = createImageFile ( imageCount , imageFormat , imgName ) ; if ( ! file . exists ( ) ) { file . getParentFile ( ) . mkdirs ( ) ; } ImageIO . write ( img , imageFormat , file ) ; imageCount ++ ; } } }
Save images into session if the ets is interactive and it contains the images .