Class ImageUtils


  • public class ImageUtils
    extends java.lang.Object
    Provides logic for screenshot and image manipulation and conversion.
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageUtils​(org.openqa.selenium.WebDriver driver)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.openqa.selenium.WebDriver getDriver()  
      byte[] handleAlertAndTakeScreenshot()
      Accepts the current alert window and takes a screenshot.
      static java.awt.image.BufferedImage toBufferedImage​(java.lang.String fileName)
      Converts the file referenced by the argument file name to a BufferedImage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ImageUtils

        public ImageUtils​(org.openqa.selenium.WebDriver driver)
    • Method Detail

      • getDriver

        public org.openqa.selenium.WebDriver getDriver()
      • handleAlertAndTakeScreenshot

        public byte[] handleAlertAndTakeScreenshot()
        Accepts the current alert window and takes a screenshot.

        The FluentLenium logo is also added on to the screenshot.

        Returns:
        the screenshot as a byte array
        Throws:
        ScreenshotNotCreatedException - if a problem occurred during reading the screenshot file
      • toBufferedImage

        public static java.awt.image.BufferedImage toBufferedImage​(java.lang.String fileName)
                                                            throws java.io.IOException
        Converts the file referenced by the argument file name to a BufferedImage.
        Parameters:
        fileName - the name of the file to convert
        Returns:
        the converted BufferedImage
        Throws:
        java.nio.file.NoSuchFileException - if the argument file cannot be found
        ScreenshotNotCreatedException - if a problem occurred during image conversion
        java.io.IOException